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

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
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,893
Messages
6,175,241
Members
452,622
Latest member
Laura_PinksBTHFT

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