select workbook

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

Hi,

I'm using a macro that opens a dialigbox to open a file.
I know the filename begins with ABC.
Fe ABC XXXXX of ABC YYYY.

Is it possible to switch between a filename that is
always the same and ABC XXXXX
The file I know I select I use
Windows("DEF.xls").Activate

Can I use something like Windows("ABC*.xls").Activate ?

Thanks
Tom
 
Hi
you may try something like the following:
sub foo()
dim wbk as workbook
For each wbk in workbooks
if ucase(left(wbk.name,3))="ABC" then
wbk.activate
exit for
end if
next
end sub
 
Hi
Nothing happens, even no error.
Tom
-----Original Message-----
Hi
you may try something like the following:
sub foo()
dim wbk as workbook
For each wbk in workbooks
if ucase(left(wbk.name,3))="ABC" then
wbk.activate
exit for
end if
next
end sub

.
 
Hi
works for me (Excel 97). What is the exact code you have
used?
 
I'm using Excell 2003

Sub test()
Dim wbk As Workbook
For Each wbk In Workbooks
If UCase(Left(wbk.Name, 3)) = "Exp" Then
wbk.Activate
ActiveSheet.Unprotect
Selection.EntireColumn.Hidden = False
With ActiveWindow
.DisplayGridlines = True
.DisplayHeadings = True
End With
Columns("A:K").Select
Selection.EntireColumn.Hidden = False

Exit For
End If
Next
Windows("Quogen NeXspan 1.0.xls").Activate


End Sub
 
This line jumped out at me. (I didn't look at anything else.)

If UCase(Left(wbk.Name, 3)) = "Exp" Then
Since you're checking uppercase stuff...
If UCase(Left(wbk.Name, 3)) = "EXP" Then
 
Dave
problem is solved
you're right! Exp has to be EXP
Thank you very much !
Tom
 

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

Back
Top