excel named ranges issue Excel 2013

Excel2006

Active Member
Joined
Dec 19, 2006
Messages
455
Hi guys

Please can you help me with this code. I am trying to update named ranges via excel vba

range name = "Building-Name" already exists.

It had less than 100 records and this had increased to over 100.

I want the macro to auto update the named range every time I add extra records.
Please would you help me. I get an error code when I try the code below.



Code:
Public Sub Example()
Range("g1:g" & Range("g1").End(xlDown).Row).Name = "Building-Name"
End Sub

Regards

excel2006
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Use =OFFSET($G$1,0,0,COUNTA($G:$G),1) for the range, it will update automatically everytime a record is added
 
Upvote 0
CHeers, Neil, but is there a way to do this in VBA as my spreadsheet contains a lot of VBA code

There's no need - set up the dynamic named ranges and they will automatically adjust as data is added / deleted. You can refer to the ranges in your code and don't need to worry about adjusting the dimensions of the ranges.
 
Upvote 0

Forum statistics

Threads
1,214,893
Messages
6,122,121
Members
449,066
Latest member
Andyg666

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top