Consulting

Results 1 to 6 of 6

Thread: Solved: How to add few sheet name

  1. #1

    Solved: How to add few sheet name

    Hi,

    How to add few more sheet name to this code i.e I want to add 2 more sheet with name "Labour - summary" and "Overall - Summary", or is there any way to get the sheet referring to their part of name such as " - summary". Any sheet have this part of name will be selected.

    Thanks,


    [vba]For Each ws In wb.Sheets
    If ws.Name = "GNI - summary" _
    Or ws.Name = "Capital - summary" Then
    ws.Copy Before:=wbThisBk.Sheets("End")
    Range("A1:AZ1000").Select
    Selection.Copy
    Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    End If
    Next ws[/vba]

  2. #2
    Hi ,

    Obviously untested, but try this:

        For Each ws In wb.Sheets
            If (InStr(ws.Name, " - summary")) > 0 Then
                ws.Copy Before:=wbThisBk.Sheets("End")
                Range("A1:AZ1000").Select
                Selection.Copy
                Range("A1").Select
                Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
                :=False, Transpose:=False
            End If
        Next ws
    HTH

    Robert

  3. #3
    Hi Robert,

    thanks a lot! It works, I should mark this tread as solve.

  4. #4
    Thanks for letting us know and I'm glad vbaexpress was able to provide a workable solution

  5. #5
    people in this forum are amazing...

  6. #6
    people in this forum are amazing...
    Thank you, that's really nice

Posting Permissions

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