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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Oaktree

MrExcel MVP
Joined
Jun 20, 2002
Messages
8,105
Office Version
  1. 365
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"
 

Forum statistics

Threads
1,181,993
Messages
5,933,157
Members
436,882
Latest member
Kiddo456

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
Top