excel vba - VBA: How to programmaticaly create named range pointing to programmatically created sheet? -


it seems question contains proper answer, excel unfathomable reason won't execute without error. question has changed bit:

why 1004?

basically want use (this give me 1004):

dim rngtmp range each offer in sanitizedconstinfo("offers").keys()     set rngtmp = sheets(offer).range(cells(1, 1), cells(2, 2))     activeworkbook.names.add name:=offer, referstor1c1:=rngtmp     activeworkbook.names(offer).referstorange.cells(1, 1) = offer next offer 

offer string containing name (yeah, want have both sheet , named range same name - @ least). have unknown number of those, loop for each.

q: how add sheet information referstor1c1, named range refers sheet? (i know 'sheetname'!a1:a10 syntax want sheet/range/cell objects if possible)

it's because aren't qualifying ranges, need explicit:

with sheets(offer)     set rngtmp = .range(.cells(1, 1), .cells(2, 2)) end 

dots before cells important.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -