VBA to create multiple named ranges

pujo

Well-known Member
Joined
Feb 19, 2009
Messages
710
Office Version
  1. 2019
  2. 2013
Platform
  1. Windows
Hello all.

In Sheet1 Column A, Cell 1-72, I have a list of names.
In Sheet1 Column B, Cell 1-72, I have a list of addresses.
Example: A1: RawData B1: =Report!$F$10:$F$17,Report!$F$19:$F$20,Report!$H$10:$H$17,Report!$H$19:$H$20,Report!$K$10:$K$12,Report!$I$15:$N$15

Is there a way I can VBA to create all the named ranges from the lists in Sheet1?

Thanks!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hi pujo,

Try this while on the sheet with the data in columns A and B:

VBA Code:
Option Explicit
Sub Macro1()

    Dim rngCell As Range

    Application.ScreenUpdating = False
    
    For Each rngCell In Range("A1:A72")
        If Len(rngCell) > 0 And Len(rngCell.Offset(0, 1)) > 0 Then
            Range(rngCell.Offset(0, 1)).Name = rngCell.Value
        End If
    Next rngCell
    
    Application.ScreenUpdating = True

End Sub

Regards,

Robert
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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