Recorded Macro - Defined Name Question

JUDYT

New Member
Joined
Oct 28, 2004
Messages
26
Below is part of a macro that I recorded and it does work. The problem is I don't understand why it works and since I often work with macros (simple ones) I would like to understand them. The part I don't understand is where I add the name. At the very end it says C7:C14" This not the range I highlighted when recording but it works. When I change the range to the actual range it does not work. Does the C7:C14 stand for something other then the actual range. This is the second macro this has happened on. The actual range is N2:G937

Just Curious


ActiveWorkbook.Names.Add Name:="Notes", RefersToR1C1:= _
"='[serviceover45-current.xls]Sheet1'!C7:C14"
Range("N2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-7],notes,8,0)"
Range("N2").Select
[N2].Copy Range("N3", Range("M65536").End(xlUp).Offset(, 1))
Range("A2").Select
 

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.
You have RefersToR1C1 but a relative address. Try
ActiveWorkbook.Names.Add Name:="Notes", RefersTo:= _
"='[serviceover45-current.xls]Sheet1'!$N$2:$G$937 "

With "RefersTo" instead of "RefersToR1C1"
 
Upvote 0

Forum statistics

Threads
1,222,437
Messages
6,166,025
Members
452,008
Latest member
Customlogoflipflops

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