![]() |
Insterting Text Into
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. |
Insterting Text Into
Windows(Sheets("Customize").Range("C27").Value).Ac tivate
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 -- Regards, Tom Ogilvy "Carl Bowman" wrote in message ... 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. |
Insterting Text Into
Thanks again. This has solved all my "puzzles". You have been very patient!
Carl "Tom Ogilvy" wrote: Windows(Sheets("Customize").Range("C27").Value).Ac tivate 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 -- Regards, Tom Ogilvy "Carl Bowman" wrote in message ... 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. |
All times are GMT +1. The time now is 06:07 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com