Is there another way besides Activesheet.Name to get which sheet is calling a macro?
I currently have code where you press a button then it runs a simulation program, then once it runs the program it goes to another sheet in the workbook and pastes information.
This works if I run the macro one at a time on each sheet, but I want to be able to run them all at the same time.
Example: I have a input sheet "Run1" that contains the button, then once the simulation is done it does something in a sheet called "Results1"
I have created duplicate sheets of "Run1" and "Results1" and incremented the number at the end
If ActiveSheet.Name = "Run1" Then
t = 1
End If
If ActiveSheet.Name = "Run2" Then
t = 2
End If
If ActiveSheet.Name = "Run3" Then
t = 3
End If
If ActiveSheet.Name = "Run4" Then
t = 4
End If
If ActiveSheet.Name = "Run5" Then
t = 5
End If
If ActiveSheet.Name = "Run6" Then
t = 6
End If
Worksheets("Results" & t).Activate
For Each A In ActiveSheet.ChartObjects("Chart 9").Chart.SeriesCollection
A.Delete
Next A
If I click all the buttons at the same time, it throws an error, because its trying to go to a Results sheet based on which Run sheet the user is currently on. And since the simulation program is running, the code doesn't complete synchronously, excel can't find the Results sheet that the first button macro is calling because it isn't active.