apply recorded macro for all sheets
I recorded a macro for a specific sheet. But my problem is, each time I
run this macro for another sheet, it is using the values of the sheet
where I created the macro. But I want this macro works for any sheet. Here
is what my code looks like:
Sub AutoGraph()
'
' AutoGraph Macro
'
' Keyboard Shortcut: Ctrl+Shift+G
'
Range("B:B,C:C").Select
Range("C1").Activate
ActiveSheet.Shapes.AddChart2(227, xlLineMarkers).Select
ActiveChart.SetSourceData source:=Range("SHEET1!$B:$B,SHEET1!$C:$C")
Range("B:B,D:D,E1,E:E").Select
Range("E1").Activate
ActiveSheet.Shapes.AddChart2(227, xlLine).Select
ActiveChart.SetSourceData source:=Range( _
"SHEET1!$B:$B,SHEET1!$D:$D,SHEET1!$E$1,SHEET1!$E:$E")
End Sub
Where SHEET1 is the sheet's name where I recorded macro. I think I need to
change this with something common for all sheet, but couldn't find out the
logic. I appreciate any comment.
No comments:
Post a Comment