Why macro runs on the same sheet?

H

Harshad

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

Roger Govier

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top