code question

  • Thread starter Thread starter Shu of AZ
  • Start date Start date
S

Shu of AZ

In the code below, if I wanted to activate any sheet with a name that
included _U.csv, is there a wildcard I can use?

Windows("Bel080607_u.csv").Activate
Range("A:C,E:E,G:G").Select
Range("G1").Activate
Selection.Delete Shift:=xlToLeft
Columns("A:A").Select
Selection.Cut
Columns("C:C").Select
Selection.Insert Shift:=xlToRight
Range("A2:C350").Select
Selection.Copy
Windows("WiseGuy66.XLT").Activate
Sheets("R1").Select
ActiveWindow.LargeScroll Down:=1
Range("B62").Select
ActiveSheet.Paste
ActiveWindow.ScrollRow = 1
Range("A1").Select
Sheets("DataSorter").Select
Range("A1").Select
End Sub
 
and close the sheet once the code is complete.

The reason for the wildcard is that the _u sheets come in different names
every day
 
Nope.

But you can loop through the workbooks collection:

Dim wkbk as workbook
dim FoundIt as boolean

Foundit = false
for each wkbk in application.workbooks
if lcase(wkbk.name) like lcase("*_U.csv") then
foundit = true
exit for
end if
next wkbk

if foundit = true then
wkbk.activate
else
msgbox "No workbook names match!"
end if
 
Back
Top