ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Why macro runs on the same sheet? (https://www.excelbanter.com/excel-discussion-misc-queries/202510-why-macro-runs-same-sheet.html)

Harshad[_2_]

Why macro runs on the same sheet?
 
I have recorded a macro, when i run it on other sheet, it runs on the same
sheet where it was created.



Roger Govier[_3_]

Why macro runs on the same sheet?
 
Hi

When the macro recorder ran, it will have used reference like

Sheets("Sheet1").Range("A1")
referring to a specific sheet location, hence it would carry out the tasks
on that sheet.
If you change all specific references to Sheets("Sheet1") (or whatever sheet
name it refers to)
to
ActiveSheet.Range("A1) etc
then it will run on whichever sheet is active at the time you run the macro.

--
Regards
Roger Govier

"Harshad" wrote in message
...
I have recorded a macro, when i run it on other sheet, it runs on the same
sheet where it was created.




All times are GMT +1. The time now is 11:38 AM.

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