Macro With Names

Drewa25

New Member
Joined
Jul 15, 2013
Messages
3
I am trying to make a marco that will define a name starting with Spot_001 that refers to Master!$A$2:$M$2 and repeats through Spot_089 or row 99. Ideally it would name as the contents of column A
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Here is something I wrote up the other day, think it should work for you, all you need to change is where the data starts (A1 or A2) but either way this should work for you.

PLEASE BACK UP YOUR EXCEL FILE BEFORE RUNNING THIS MACRO
Code:
Sub NamedRanges()

Dim rngCell As Range
Dim intLstRow As Integer

intLstRow = ActiveSheet.UsedRange.Rows.Count
counter = 2 'If the data starts in A1, changes this to 1

For Each rngCell In Range("A2:A" & intLstRow) ' If the data Starts in A1, changes this to A1
ActiveWorkbook.Names.Add Name:=rngCell.Value, RefersTo:=Range("Master!" & rngCell.Address & ":$M$" & counter)
counter = counter + 1
Next


End Sub
PLEASE BACK UP YOUR EXCEL FILE BEFORE RUNNING THIS MACRO
 
Upvote 0

Forum statistics

Threads
1,216,756
Messages
6,132,520
Members
449,733
Latest member
Nameless_

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