Hi
Hoping somebody can help please.
Have been using the record macro feature and have managed to create the macros I need and attach them to a button, but I can only get them to work in the worksheet where the button is
What would I need to add to my code to specify 'Sheet 3" as the only sheet for the particular macro to run on?
Thanks in advance
Good Luck this week to those trading/betting at Cheltenham
Worksheet Select Macro
The macro will run on whatever sheet is active at the time.
You can write something along the lines of:
Sheets("Sheet3").Range("A2").formula..........
Sheets("Sheet3").Range("B2")=.........
But it's easier to use "With", then you don't need all that typing.
With Sheets("Sheet3")
.Range("A2").formula..........
.Range("B2")=.........
.other code............
End With
Just remember to preface each instruction with a dot.
Cheers.
You can write something along the lines of:
Sheets("Sheet3").Range("A2").formula..........
Sheets("Sheet3").Range("B2")=.........
But it's easier to use "With", then you don't need all that typing.
With Sheets("Sheet3")
.Range("A2").formula..........
.Range("B2")=.........
.other code............
End With
Just remember to preface each instruction with a dot.
Cheers.
Forgot to say that the easiest way would be just to put
Sheets("Sheet3").Select
at the beginning of the macro. But that creates it's own problems as you could find it crashing if you switch to another sheet while it's running. All depends on what you need to do.
Sheets("Sheet3").Select
at the beginning of the macro. But that creates it's own problems as you could find it crashing if you switch to another sheet while it's running. All depends on what you need to do.