Insert Names Macro

derickc

New Member
Joined
May 28, 2002
Messages
23
I'm trying to create a macro that will insert the column heading as a name for the entire selection in rows 7 through 1310 beneath each column heading (which is in Row6). When trying the following, I get an "invalid name" error message. Any clues? Thank you.


Sub InsertName()
'
' InsertName Macro
' Macro recorded 8/29/2002 by Derick Cooper
'

'

Dim lngCol As Long

For lngCol = 5 To 10
Range(Cells(7, lngCol), Cells(1310, lngCol)).Select
ActiveWorkbook.Names.Add Name:=Cells(6, lngCol).Text, RefersToR1C1:= _
"='Standard Deviations'!R7C[lngCol]:R1310C[lngCol]"

Next lngCol

End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

derickc

New Member
Joined
May 28, 2002
Messages
23
The problem is apparently in the following code:

"='Standard Deviations'!R7C[lngCol]:R1310C[lngCol]"
 

derickc

New Member
Joined
May 28, 2002
Messages
23
This is the speghetti theory of coding. I just keep changing things til something works. I changed to from the R1C1 reference style to this: RefersTo:= "='Standard Deviations'!Range(Cells(7,lngCol), Cells(1310, lngCol))"

Which has apparently worked. When I look under names/define all my new names are there, but when I try to "Goto" one of the new names it isn't recognized.

Any clues?

-dc
 

Jim North

MrExcel MVP
Joined
Jun 20, 2002
Messages
791
change:

"='Standard Deviations'!R7C[lngCol]:R1310C[lngCol]"

to:

"='Standard Deviations'!R7C" & lngCol & ":R1310C" & lngCol
 

Forum statistics

Threads
1,148,530
Messages
5,747,234
Members
424,070
Latest member
smanni3

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