VBA to Create Range Names from references

Yoepy

New Member
Joined
Feb 22, 2015
Messages
44
Hello, I hope someone can help.
I need some VBA to create 3 Range names based on column references. My problem is that there may be 100's so I would prefer not to do it manually.

I can create the references based on the columns, so column B would be as follows:

What is the code to look at the cell reference that contains the range name "EVENT1" and give it the reference $A$3:$B$23.

The Name "EVENT1" is in cell B26 and reference $A$3:$B$23 is in B30 (if that makes any difference).

Don't worry about a loop to do it multiple times.
Range name 1
EVENT1
Range name 2
EVENT1LessByes
Range name 3
EVENT1Names
Range1 Reference
$A$3:$B$23
Range2 Reference
$A$4:$B$23
Range3 Reference
$B$3:$B$23



<tbody>
</tbody>
Thank you
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
It is not clear to me where your second and third names and ranges are so here is some code that will create a named range using the B26 and B30
Code:
Sub test()
   Dim ref2 As Range
   
    Nme = Range("B26")
    ref = Range("B30")
    wksnme = ActiveSheet.Name
    Set ref2 = Range(wksnme & "!" & ref)
    ActiveWorkbook.Names.Add Name:=Nme, RefersTo:=ref2


End Sub
 
Upvote 0

Forum statistics

Threads
1,217,188
Messages
6,135,101
Members
449,911
Latest member
Omarahmed99

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