If the workbook and the string have the same name, the workbook should also
include the .xls extension. If the cell has that extension, then the
worksheet won't work.
You cannot have a variable to reference the book and sheet without some
manipulation, such as, if A1 has the value "ABC", then
Sub test()
Dim AString
AString = Sheets("Input").Range("A1").Value
Windows(AString & ".xls").Activate = works
Sheets(AString).Select = doesn't work
End Sub
What is the exact value in A1?
--
HTH
RP
(remove nothere from the email address if mailing direct)
"Hans Weustink" wrote in message
...
In the Cell is a (changing) number that corresponds to a sheet with the
same
name, however the code gives an error: "subscript out of range"
So what do I have to change to the code, because I can't get it to work.
Or do you have an exmple when it does work?
Thanks,
Hans
"Bob Phillips" wrote:
What do you have in that cell? What error do you get?
--
HTH
RP
(remove nothere from the email address if mailing direct)
"Hans Weustink" <Hans wrote in
message
...
Hi,
I'm able to selecet a workbook, but not a sheet based on a reference
like
so:
Sub test()
Dim AString
AString = Sheets("Input").Range("A1").Value
Windows(AString).Activate = works
Sheets(AString).Select = doesn't work
End Sub
Can someone think of a (alternative) way it will work?
Thanks in advance,
Hans Weustink