Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error with Goto command
Below is a piece of a larger macro. What this is suppose to do is to
open up another workbook, then come back, and select the folder Official List. Then it's suppose to Goto a named ranged Age. If I run this little part without opening up the other file, it works fine. The strange thing is that even with the error on the line Application.Goto Reference:="Age" I see that it opened up the other workbook ok, and it selected the folder Official List ( I had selected a different folder prior to running the macro, to make sure that line worked.) The cursor is at A1. Why would that Goto line work when the other workbook is NOT opened, but but I get the error when it's not opened? I know using Goto is not acceptable to some, but I've tried using variations of a .Select command without success, and the Goto command always works for me..... Thanks for your help. J.O. Workbooks.Open Filename:= _ "\\ceddfssrv01\cedroot\public\Furniture Staging List\Year old list - Current Year.xls" ActiveWindow.ActivatePrevious Worksheets("Official List").Activate Application.Goto Reference:="Age" '<<<<error on this line ActiveCell.Offset(1, 0).Select End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error with Goto command
I suspect that after opening the other file, the other file becomes
active, and since the range named "age" is not fully qualified (e.g. does not include the file name), Excel is trying to find the range on the wrong sheet. You can fix it by reactivating the sheet with 'age" on it, or including the file name before the range name in the GoTo line. Good luck. Ken excelnut1954 wrote: Below is a piece of a larger macro. What this is suppose to do is to open up another workbook, then come back, and select the folder Official List. Then it's suppose to Goto a named ranged Age. If I run this little part without opening up the other file, it works fine. The strange thing is that even with the error on the line Application.Goto Reference:="Age" I see that it opened up the other workbook ok, and it selected the folder Official List ( I had selected a different folder prior to running the macro, to make sure that line worked.) The cursor is at A1. Why would that Goto line work when the other workbook is NOT opened, but but I get the error when it's not opened? I know using Goto is not acceptable to some, but I've tried using variations of a .Select command without success, and the Goto command always works for me..... Thanks for your help. J.O. Workbooks.Open Filename:= _ "\\ceddfssrv01\cedroot\public\Furniture Staging List\Year old list - Current Year.xls" ActiveWindow.ActivatePrevious Worksheets("Official List").Activate Application.Goto Reference:="Age" '<<<<error on this line ActiveCell.Offset(1, 0).Select End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error with Goto command
Thanks for the reply, Ken. But, as I said, I DO have the original
workbook activated. And, it actually does come back. I can tell because it activates the sheet Official List. Before running this, I tested it by activating another sheet 1st. At the time of the error, I can switch to the workbook, and the Official List sheet is activated. So, it appears to work up to the Goto command. Is there a Select command I can to go to the range? Ken wrote: I suspect that after opening the other file, the other file becomes active, and since the range named "age" is not fully qualified (e.g. does not include the file name), Excel is trying to find the range on the wrong sheet. You can fix it by reactivating the sheet with 'age" on it, or including the file name before the range name in the GoTo line. Good luck. Ken excelnut1954 wrote: Below is a piece of a larger macro. What this is suppose to do is to open up another workbook, then come back, and select the folder Official List. Then it's suppose to Goto a named ranged Age. If I run this little part without opening up the other file, it works fine. The strange thing is that even with the error on the line Application.Goto Reference:="Age" I see that it opened up the other workbook ok, and it selected the folder Official List ( I had selected a different folder prior to running the macro, to make sure that line worked.) The cursor is at A1. Why would that Goto line work when the other workbook is NOT opened, but but I get the error when it's not opened? I know using Goto is not acceptable to some, but I've tried using variations of a .Select command without success, and the Goto command always works for me..... Thanks for your help. J.O. Workbooks.Open Filename:= _ "\\ceddfssrv01\cedroot\public\Furniture Staging List\Year old list - Current Year.xls" ActiveWindow.ActivatePrevious Worksheets("Official List").Activate Application.Goto Reference:="Age" '<<<<error on this line ActiveCell.Offset(1, 0).Select End Sub |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Error with Goto command
Just to follow up in case anyone can get something from this.....
I found some code in here that worked to replace the Goto command. I inserted this: With Sheets("Official List") .Select .Range("Age").Select ActiveCell.Offset(1, 0).Select End With And, it works fine. So, I guess it is true that sometimes the Goto command is not the best choice. I have no idea why it didn't work in this case. I've used is successfully lots of times. J.O. excelnut1954 wrote: Thanks for the reply, Ken. But, as I said, I DO have the original workbook activated. And, it actually does come back. I can tell because it activates the sheet Official List. Before running this, I tested it by activating another sheet 1st. At the time of the error, I can switch to the workbook, and the Official List sheet is activated. So, it appears to work up to the Goto command. Is there a Select command I can to go to the range? Ken wrote: I suspect that after opening the other file, the other file becomes active, and since the range named "age" is not fully qualified (e.g. does not include the file name), Excel is trying to find the range on the wrong sheet. You can fix it by reactivating the sheet with 'age" on it, or including the file name before the range name in the GoTo line. Good luck. Ken excelnut1954 wrote: Below is a piece of a larger macro. What this is suppose to do is to open up another workbook, then come back, and select the folder Official List. Then it's suppose to Goto a named ranged Age. If I run this little part without opening up the other file, it works fine. The strange thing is that even with the error on the line Application.Goto Reference:="Age" I see that it opened up the other workbook ok, and it selected the folder Official List ( I had selected a different folder prior to running the macro, to make sure that line worked.) The cursor is at A1. Why would that Goto line work when the other workbook is NOT opened, but but I get the error when it's not opened? I know using Goto is not acceptable to some, but I've tried using variations of a .Select command without success, and the Goto command always works for me..... Thanks for your help. J.O. Workbooks.Open Filename:= _ "\\ceddfssrv01\cedroot\public\Furniture Staging List\Year old list - Current Year.xls" ActiveWindow.ActivatePrevious Worksheets("Official List").Activate Application.Goto Reference:="Age" '<<<<error on this line ActiveCell.Offset(1, 0).Select End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
command code ( GOTO command) in formula | New Users to Excel | |||
USING A GOTO COMMAND IN EXCEL | Excel Worksheet Functions | |||
Goto Command in Code | Excel Programming | |||
search or goto command needed. | Excel Programming |