ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Runs in macro but not in procedure...why? (https://www.excelbanter.com/excel-programming/364777-runs-macro-but-not-procedure-why.html)

Billy B

Runs in macro but not in procedure...why?
 
In trying to code a procdure I want to have range A5 as the starting location
for each sheet (to be used in code later as the active cell for each sheet
when made active.) I was having trouble so I recorded the key stroke as a
macro and it works. I copy the code to a procedure, run it from a command
button and I get the following error msg: Select method of Range Class failed.

Here is the simple code:
Sheets("Sheet1").Select
Range("A5").Select
Sheets("Sheet2").Select
Range("A5").Select

Help is appreciated.

Leith Ross[_587_]

Runs in macro but not in procedure...why?
 

Hello Billy B,

I suspect your procedure code is in the General Declarations section of
a Worksheet. Add a Module to your project and place the code there and
it should work fine.

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=553485



All times are GMT +1. The time now is 04:47 AM.

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