PDA

View Full Version : Solved: How to add few sheet name



halimi1306
08-03-2011, 08:10 PM
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,


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

Trebor76
08-03-2011, 09:27 PM
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

halimi1306
08-03-2011, 10:16 PM
Hi Robert,

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

Trebor76
08-03-2011, 10:43 PM
Thanks for letting us know and I'm glad vbaexpress was able to provide a workable solution ;)

halimi1306
08-03-2011, 10:50 PM
people in this forum are amazing...

Trebor76
08-04-2011, 01:46 AM
people in this forum are amazing...

Thank you, that's really nice :)