View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
kittronald kittronald is offline
external usenet poster
 
Posts: 162
Default Creating a defined name's Refersto range

I'm trying to create a defined name's Refersto range of
"Sheet1!$A$1:$A$5" using the variable below.

r = 5

Workbooks("Book1.xlsb").Names.Add Name:="Test",
RefersTo:=Sheets("Sheet1").Range("A1").Resize(r - 1, 0)

This doesn't work and gives a Run-time error '9': Subscript out of range
error.

What is the code to get the Refersto range properly setup ?


kittronald