Define Name by vba

Forestq

Active Member
Joined
May 9, 2010
Messages
482
Hi,

I'm using "Name Manager" in Formulas Tab to define LIST. Exaclty the same I want to do using VBA.

I have:
Code:
=OFFSET('Country'!$E$9,0,0,COUNTA('Country lvl'!$E$9:$E$20),1)

Into VB:
Code:
rows_x = ws.Cells(Rows.Count, "A").End(xlUp).Row

wb_1.Names.Add Name:="Country_list", RefersToR1C1:= _
        "=OFFSET('Country lvl'!R9C5,0,0,COUNTA('Country lvl'!R9C5:R10C5),1)"

But I dont know how to change the range to: !$E$9:$E$rows_x
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Like this?

Rich (BB code):
wb_1.Names.Add Name:="Country_list", RefersToR1C1:= _
        "=OFFSET('Country lvl'!R9C5,0,0,COUNTA('Country lvl'!R9C5:R" & rows_x & "C5),1)"
 
Upvote 0

Forum statistics

Threads
1,215,523
Messages
6,125,320
Members
449,218
Latest member
Excel Master

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