Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Automate defining names

VBA snippet:

week = InputBox("Enter the week number", week)
ActiveWorkbook.Names.Add Name:="Eddie", RefersToR1C1:="='11'!R2C2"

Two things I need to do:

1. Substitute week for '11' (having syntax problem).
2. AND week with Eddie (for example =" "Eddie" & week")

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,173
Default Automate defining names

Johnny

try this

week = InputBox("Enter the week number", week)
ActiveWorkbook.Names.Add Name:="Eddie_" & week, RefersToR1C1:="=" & week &
"!R2C2"

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS

"Johnny" wrote in message
oups.com...
VBA snippet:

week = InputBox("Enter the week number", week)
ActiveWorkbook.Names.Add Name:="Eddie", RefersToR1C1:="='11'!R2C2"

Two things I need to do:

1. Substitute week for '11' (having syntax problem).
2. AND week with Eddie (for example =" "Eddie" & week")



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Automate defining names

Nick,

Works as requested, thank you. But here's a followup question if you
don't mind:

Instead of hard-coding the names (ie. Eddie), what would the syntax
change be to get the name from the adjacent cell (ex. B2). I've tried
substituting both B2 and R2C2, and I get a run-time error 1004.

Thanks again
John

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Automate defining names

week = InputBox("Enter the week number", week)
ActiveWorkbook.Names.Add Name:= Range("B2").Value & "_" & week,
RefersToR1C1:="=" & week & "!R2C2"

or if it is relative (one column to the right) to the activecell then

week = InputBox("Enter the week number", week)
ActiveWorkbook.Names.Add Name:= Activecell.Offset(0,1).Value & "_" & week, _
RefersToR1C1:="=" & week & "!R2C2"

--
HTH

Bob Phillips

"Nick Hodge" wrote in message
...
Johnny

try this

week = InputBox("Enter the week number", week)
ActiveWorkbook.Names.Add Name:="Eddie_" & week, RefersToR1C1:="=" & week &
"!R2C2"

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS

"Johnny" wrote in message
oups.com...
VBA snippet:

week = InputBox("Enter the week number", week)
ActiveWorkbook.Names.Add Name:="Eddie", RefersToR1C1:="='11'!R2C2"

Two things I need to do:

1. Substitute week for '11' (having syntax problem).
2. AND week with Eddie (for example =" "Eddie" & week")





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Automate defining names

Bob, Nick,

Huge help! Many thanks.

John

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
defining names in a macro guidop12 Excel Discussion (Misc queries) 6 August 28th 08 11:56 PM
Help with defining names [email protected] Excel Worksheet Functions 3 February 14th 08 08:34 AM
Defining Names in Excel RadioTraffic Excel Worksheet Functions 3 January 10th 07 02:41 AM
Automating defining names Sid DeLuca Excel Programming 1 December 4th 03 07:29 PM
Defining Names russell \(skmr3\) Excel Programming 1 July 25th 03 02:24 AM


All times are GMT +1. The time now is 02:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"