code question

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
 
S

Shu of AZ

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
 
D

Dave Peterson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top