extending excel named range with vba

  • Thread starter Thread starter Hugo & Monique
  • Start date Start date
H

Hugo & Monique

Hi,

I am trying to resize a named range (extracted from a database) according to
the actual number of rows which varies each time I dump records from that
database.
Since I don't want to do this manually each time, I would like to automate
this task. Can someone give me a hint on how this can be done in VBA ?

Thank you !

Monique
Belgium
 
Set rng = ActiveSheet.UsedRange

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
ActiveWorkbook.Names.Add Name:="hello", RefersToR1C1:="=Sheet1!R66C32:R67C40"

where "hello" is the name of the range
and Sheet1 is the nanme of the sheet.
this will overwrite any existing range so do not worry about having to
modify it

R66C32 = upper left bound of range. R67C40 = lower right bound
substitute rows and columns as needed
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top