Insterting Text Into

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to change windows using the following code whereas the name of
the file is located in cell "C27" of the worksheet "Customize":
Windows("" & Sheets("Customize").Range("C27").Value & "").Activate
The code is not working (I've tried several variations). Please Advise.
Thanks.
 
Windows(Sheets("Customize").Range("C27").Value).Activate
or
Windows(Sheets("Customize").Range("C27").Value & ".xls").Activate

if you don't have .xls on the end of your workbook name.

of course if you are not in the workbook that contains sheet Customize
(assume workbook name is Test.xls)


Dim bk as workbook, bk1 as workbook
Dim sStr as String
set bk = workbooks("Test.xls")
sStr = bk.Worksheets("Customize").Range("C27").Value
if lcase(right(sStr,4)) <> ".xls" then
sStr = sStr & ".xls"
end if
On error resume next
set bk1 = Workbooks(sStr)
On Error goto 0
if bk1 is nothing then
msgbox sStr & " is not an existing open workbook"
else
bk1.Activate
End if
 
Thanks again. This has solved all my "puzzles". You have been very patient!
Carl
 

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


Back
Top