Command buttons and code - help!!
Hi everyone,
OK, so i have a Worksheet with five command buttons on, i.e. RunASH_Mon,
RunASH_Tues etc etc
I call the following code on each of the buttons (there is actually 10
worksheets all with five buttons with the same names), and this works fine
but I want to be able to pass the command button name, as I have with the
worksheet name, so that I only have one sub routine instead of five.
Sub RunASHMon(SheetN As String)
Application.ScreenUpdating = False
Sheets("Data").Activate
ActiveSheet.Range("A1:D119").Copy
Sheets(SheetN).Activate
ActiveSheet.Range("A6").Select
ActiveSheet.Paste
Application.ScreenUpdating = True
End Sub
Any ideas how I would do this, maybe with as IF....THEN statement? Basically
I want it to say,
IF (the command button name is RunASH_Mon and has been clicked) THEN
ActiveSheet.Range ("A6").Select.Paste
IF (RunASH_Tues has been clicked) THEN
ActiveSheet.Range("G6").Select.Paste
etc etc
Any help would be greatly appreciated
Cheers
Lindsey M
|