ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macros (https://www.excelbanter.com/excel-programming/275947-macros.html)

marijo

Macros
 
How do I create a link to a worksheet using macros? I recorded a macro
while typing in a worksheet, then inserted another worksheet and placed
an object to assign it with an existing macro. I got a warning that
says, Run-time error '9': Subscript out of range. Can someone please
teach me how to fix this?

Greg Wilson[_3_]

Macros
 
The error message implies that you referenced a
nonexistent member of a collection. In other words, you
have a reference in your code to a worksheet, shape
object, element in an array or other member of a
collection that does not exist. Most often, this results
from an invalid reference to the object.

You need to look at all references to objects, in
particular worksheets and shape objects to ensure that
their referencing is valid. I'm going to guess that you
selected a shape object (command button, chart, rectangle
etc.) on the worksheet and your recorded code reflected
this as "ActiveSheet.Shapes("CommandButton1").Select" or
something similar. If you run the code from another
worksheet then it becomes the active sheet and there is
probably no "CommandButton1" on this sheet.

If you have difficulty resolving the problem, post your
code and we should be able to fix it.

Regards,
Greg


-----Original Message-----
How do I create a link to a worksheet using macros? I

recorded a macro
while typing in a worksheet, then inserted another

worksheet and placed
an object to assign it with an existing macro. I got a

warning that
says, Run-time error '9': Subscript out of range. Can

someone please
teach me how to fix this?
.


marijo[_3_]

Macros
 
Greg,

Thanks so much for the reply. I have already fixed it. :)


Marij

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 02:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com