VBA to create multiple named ranges

pujo

Well-known Member
Joined
Feb 19, 2009
Messages
708
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

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
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,215,432
Messages
6,124,856
Members
449,194
Latest member
HellScout

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