Results 1 to 8 of 8

How Do I Move/Count specific Sheets using Wildcard Characters?

Threaded View

  1. #1
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,522

    How Do I Move/Count specific Sheets using Wildcard Characters?

    How Do I Move/Count specific Sheets using Wildcard Characters?

    Dear Forum,

    I have to Count and Move only specific Sheet Names whose Sheet Names end in "*Planning"

    Can you please help me with a VBA code for the above.

    I need to MOve specific Sheets to a New WorkBook which is created Dynamically...

    Sub MoveSheets()
    
      Dim FileSpec As String
      Dim i As Integer
      Dim NewWkb As Workbook
      Dim Wks As Worksheet
      Dim WksName As String
      Dim FolderPath As String
      
        With ThisWorkbook.Worksheets("Replicator")
          FileSpec = .Range("C3") ' Folder Path
                    mkdir(FolderPath)
          FileSpec = .Range("C3") ' Path
          FileSpec = IIf(Right(FileSpec, 1) <> "\", FileSpec & "\", FileSpec)
          FileSpec = FileSpec & .Range("C2") ' Path and the New WorkBook or FileName
          
          ActiveWorkbook.Sheets.Count
          
            For i = 1 To .Range("C4") ' Count the No of Sheets to Be Moved
              WksName = .Cells(i + 4, "C")
              Set Wks = ThisWorkbook.Worksheets(WksName)
                If NewWkb Is Nothing Then
                   Wks.Move
                   Set NewWkb = ActiveWorkbook
                Else
                   Wks.Move After:=NewWkb.Worksheets(NewWkb.Worksheets.Count)
                End If
            Next i
                
                            
          NewWkb.SaveAs FileSpec
          NewWkb.Close SaveChanges:=False
       End With
       
    End Sub
    The above code was provided to me by Leith Ross, I have just added the Folder Option but I want to modify the code further when the FOlder Exists if we can also delete the Folder and the files in the Folder..

    Warm Regards
    e4excel
    Last edited by e4excel; 03-24-2011 at 03:58 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1