excel - Reference must be on the active sheet error -
i getting reference must on active sheet error
on last line.
for each ws in tabarr() ws select case .name case "summary" area = "prnsummary" title = "$1:$9" case "monthly cc sum" area = "prnmonthlyccsum" title = "$2:$16" case .name = "div sal sum" area = "prndivsalsum" title = "" case .name = "cc sal sum" area = "prnccsalsum" title = "$2:$16" end select .pagesetup .printarea = area '<----error here
i have tried creating worksheet
object.
dim ws worksheet each e in tabarr() set ws = e debug.print ws.name ws ...
but still failed :/ odd thing is, prints first worksheet. fails on second.
in first 2 case
statements have literal string. in 3rd , 4th case
statements have .name = literal