I am want to run a macro on a specific sheet by pressing a command button that is in another sheet. The code I have is:
Sub FormatData ()
Dim Lr As Long
Dim ws As Worksheet
Set ws = Sheets("NewData")
Application.ScreenUpdating = False
the rest of the code after that.
The problem is that the macro runs on the active sheet (ie the sheet the button is on). I've looked at all the previous posts about this but, as there seems to be a different answer every time this question is asked, I am very confused as to how to correct/change my code so that the macro runs on the correct sheet.
Any help would be appreciated.
Sub FormatData ()
Dim Lr As Long
Dim ws As Worksheet
Set ws = Sheets("NewData")
Application.ScreenUpdating = False
the rest of the code after that.
The problem is that the macro runs on the active sheet (ie the sheet the button is on). I've looked at all the previous posts about this but, as there seems to be a different answer every time this question is asked, I am very confused as to how to correct/change my code so that the macro runs on the correct sheet.
Any help would be appreciated.