ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   name a range from the current activecell down 12 rows (https://www.excelbanter.com/excel-programming/438140-name-range-current-activecell-down-12-rows.html)

BRC[_2_]

name a range from the current activecell down 12 rows
 
Hi,
I know this is probably very simple but I can't find the code i need
and when I try to record as a macro i get hard coded addesses (c7.c19)
rather then just something like "xldown 12." and since the starting
address varies, the hardcoded address don't help. I want to select the
activecell and 12 or 13 down and then give that range a name. Thk in
advance for any help.

Peter T

name a range from the current activecell down 12 rows
 
ActiveCell.Resize(13, 1).Name = "myName"

MsgBox Range("myName").Name

Regards,
Peter T


"BRC" wrote in message
...
Hi,
I know this is probably very simple but I can't find the code i need
and when I try to record as a macro i get hard coded addesses (c7.c19)
rather then just something like "xldown 12." and since the starting
address varies, the hardcoded address don't help. I want to select the
activecell and 12 or 13 down and then give that range a name. Thk in
advance for any help.




Benito Merino

name a range from the current activecell down 12 rows
 
On 8 ene, 08:49, BRC wrote:
Hi,
I know this is probably very simple but I can't find the code i need
and when I try to record as a macro i get hard coded addesses (c7.c19)
rather then just something like "xldown 12." *and since the starting
address varies, the hardcoded address don't help. I want to select the
activecell and 12 or 13 *down and then give that range a name. *Thk in
advance for any help.


Hi BRC,

Try this code:

ActiveWorkbook.Names.Add Name:="namerange", RefersTo:=ActiveCell.Resize
(12, 1)

Regards,

Benito
Barcelona
Spain

BRC[_2_]

name a range from the current activecell down 12 rows
 
On Jan 8, 12:05*am, Benito Merino wrote:
On 8 ene, wrote:

Hi,
I know this is probably very simple but I can't find the code i need
and when I try to record as a macro i get hard coded addesses (c7.c19)
rather then just something like "xldown 12." *and since the starting
address varies, the hardcoded address don't help. I want to select the
activecell and 12 or 13 *down and then give that range a name. *Thk in
advance for any help.


HiBRC,

Try this code:

ActiveWorkbook.Names.Add Name:="namerange", RefersTo:=ActiveCell.Resize
(12, 1)

Regards,

Benito
Barcelona
Spain


Thank you gentlemen for the help worked great


All times are GMT +1. The time now is 07:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com