View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Add a Dynamic Name Range

Try this

ActiveWorkbook.Cells(CompanyData.Rows.Count + 1,
CompanyData.Columns.Count).Name="CompanyXrefRange"

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Fredriksson via OfficeKB.com" <u27002@uwe wrote in message
news:70295e96df0ca@uwe...
Using This Workbook module, I need to set up Name Ranges everytime the
Work
Book is Open but the size of the range may change between each opening and
the user may delete a range when open.

When I recorded a Name defining Macro, it produce this code.
ActiveWorkbook.Names.Add Name:="CompanyXrefRange", RefersToR1C1:= _
"='Xref Property'!R2C1:R3182C4"

When I resize the range in my code I use this code
CompanyXrefRange.Resize(CompanyData.Rows.Count + 1,
CompanyData.Columns.Count)
Name = "CompanyXrefRange"

Can I combine the two concept above so when This Workbook is executed it
will
coount the rows and the columns to create the appropriate size of the
Range

Thanks

--
Message posted via http://www.officekb.com