View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default VBA Code Efficiency Question

For efficiency, probably not, but you can loop:

week = InputBox("Enter the NASCAR Week", NASCAR_Week)
for i = 0 to 9 step 3
ActiveWorkbook.Names.Add name:=Range("A2") _
.Offset(0,i).Value & week,RefersToR1C1:= _
"=" & week & "!R2C" & i + 2
Next


--
Regards,
Tom Ogilvy



"Johnny" wrote in message
oups.com...
Can this code be paired-down for more efficiency?

week = InputBox("Enter the NASCAR Week", NASCAR_Week)
ActiveWorkbook.Names.Add name:=Range("A2").Value & week,
RefersToR1C1:="=" & week & "!R2C2"
ActiveWorkbook.Names.Add name:=Range("D2").Value & week,
RefersToR1C1:="=" & week & "!R2C5"
ActiveWorkbook.Names.Add name:=Range("G2").Value & week,
RefersToR1C1:="=" & week & "!R2C8"
ActiveWorkbook.Names.Add name:=Range("J2").Value & week,
RefersToR1C1:="=" & week & "!R2C11"

Thanks for checking this out.
John