Excel - Macro Changing sheets and Fill to End - Compile Error -
i creating macro run consecutively on 25 sheets, naming cells in specific column. have code filling end, , changing sheets. when combine codes, getting warning:
compile error: duplicate declaration in current scope
when remove dim definition, run on consecutive sheets, end of first sheet. goal have each sheet dynamically filled end in column n set name each.
here code working on
sub mailbox_name() ' ' mailbox_name macro ' adds mailbox name each sheet ' dim lr long lr = cells.find(what:="*", searchdirection:=xlprevious, searchorder:=xlbyrows).row range("n1").select activecell.formular1c1 = "mailbox" range("n2").select activecell.formular1c1 = "acc" range("n2").select selection.autofill destination:=range("n2:n" & lr) range("n2:n" & lr).select selection.copy sheets("acpr").select dim lr long lr = cells.find(what:="*", searchdirection:=xlprevious, searchorder:=xlbyrows).row range("n1").select activecell.formular1c1 = "mailbox" range("n2").select activecell.formular1c1 = "acpr" range("n2").select selection.autofill destination:=range("n2:n" & lr) range("n2:n" & lr).select end sub
thanks can provide!
just read error telling - have duplicate declaration. sure enough, in code have dim lr long
twice.
Comments
Post a Comment