excel - apply recorded macro for all sheets -


i recorded macro specific sheet. problem is, each time run macro sheet, using values of sheet created macro. want macro works sheet. here 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 sheet's name recorded macro. think need change common sheet, couldn't find out logic. appreciate comment.

you have sheet hardcoded. why doing this.

one way remove references sheet1. cause excel default whatever sheet on.

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("$b:$b,$c:$c")     range("b:b,d:d,e1,e:e").select     range("e1").activate     activesheet.shapes.addchart2(227, xlline).select     activechart.setsourcedata source:=range( _         "$b:$b,$d:$d,$e$1,$e:$e") end sub 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -