Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 399
Default Create named range for each column not working?

I'm attempting to loop through all the columns in the UsedRange and create a
named range for each one. It loops, and all strings are correct - I just
don't have any ranges when it's finished! What have I done wrong?

Ed

Set wb = ActiveWorkbook
Set ws = wb.ActiveSheet
cntCol = ws.UsedRange.Columns.Count
cntRow = ws.UsedRange.Rows.Count

' Set name for each column range
cntRng = 1
For i = 1 To cntCol
strRng = i
strAddr = ws.Name & "!C" & strRng
strRng = "col" & strRng
wb.Names.Add _
Name:=strRng, _
RefersToR1C1:=strAddr
Next i


  #2   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 399
Default range for each column - more info

I checked under InsertNameDefine, and all the names I just created are
there, and the addresses are correct - EXCEPT the show up as ="Sheet3!C1" ,
unlike other names that don't have the quotes. These names are not showing
up in the name box in the formula bar, although they are listed under
Define.

Does this help with a solution?

Ed

"Ed" wrote in message
...
I'm attempting to loop through all the columns in the UsedRange and create

a
named range for each one. It loops, and all strings are correct - I just
don't have any ranges when it's finished! What have I done wrong?

Ed

Set wb = ActiveWorkbook
Set ws = wb.ActiveSheet
cntCol = ws.UsedRange.Columns.Count
cntRow = ws.UsedRange.Rows.Count

' Set name for each column range
cntRng = 1
For i = 1 To cntCol
strRng = i
strAddr = ws.Name & "!C" & strRng
strRng = "col" & strRng
wb.Names.Add _
Name:=strRng, _
RefersToR1C1:=strAddr
Next i




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Create named range for each column not working?

This works for me


Set wb = ActiveWorkbook
Set ws = wb.ActiveSheet
cntCol = ws.UsedRange.Columns.Count
cntRow = ws.UsedRange.Rows.Count

' Set name for each column range
cntRng = 1
For i = 1 To cntCol
strRng = i
strAddr = "=" & ws.Name & "!C" & strRng
strRng = "col" & strRng
wb.Names.Add _
Name:=strRng, _
RefersToR1C1:=strAddr
Next i


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Ed" wrote in message
...
I'm attempting to loop through all the columns in the UsedRange and create

a
named range for each one. It loops, and all strings are correct - I just
don't have any ranges when it's finished! What have I done wrong?

Ed

Set wb = ActiveWorkbook
Set ws = wb.ActiveSheet
cntCol = ws.UsedRange.Columns.Count
cntRow = ws.UsedRange.Rows.Count

' Set name for each column range
cntRng = 1
For i = 1 To cntCol
strRng = i
strAddr = ws.Name & "!C" & strRng
strRng = "col" & strRng
wb.Names.Add _
Name:=strRng, _
RefersToR1C1:=strAddr
Next i




  #4   Report Post  
Posted to microsoft.public.excel.programming
Ed Ed is offline
external usenet poster
 
Posts: 399
Default Create named range for each column not working?

I forgot the "=" in the strAddr!! *sigh* Well, at least I know I had the
code right. Now if I could just *proof* it right!

Thanks, Bob.
Ed

"Bob Phillips" wrote in message
...
This works for me


Set wb = ActiveWorkbook
Set ws = wb.ActiveSheet
cntCol = ws.UsedRange.Columns.Count
cntRow = ws.UsedRange.Rows.Count

' Set name for each column range
cntRng = 1
For i = 1 To cntCol
strRng = i
strAddr = "=" & ws.Name & "!C" & strRng
strRng = "col" & strRng
wb.Names.Add _
Name:=strRng, _
RefersToR1C1:=strAddr
Next i


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Ed" wrote in message
...
I'm attempting to loop through all the columns in the UsedRange and

create
a
named range for each one. It loops, and all strings are correct - I

just
don't have any ranges when it's finished! What have I done wrong?

Ed

Set wb = ActiveWorkbook
Set ws = wb.ActiveSheet
cntCol = ws.UsedRange.Columns.Count
cntRow = ws.UsedRange.Rows.Count

' Set name for each column range
cntRng = 1
For i = 1 To cntCol
strRng = i
strAddr = ws.Name & "!C" & strRng
strRng = "col" & strRng
wb.Names.Add _
Name:=strRng, _
RefersToR1C1:=strAddr
Next i






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
copy contents of a named range to a section on working area Steve Excel Discussion (Misc queries) 1 May 22nd 09 10:36 PM
Named Range Links not working Fleone Links and Linking in Excel 1 November 12th 08 07:49 AM
My Dynamic Named Range isn't working Carrie_Loos via OfficeKB.com Excel Worksheet Functions 11 February 22nd 08 10:09 PM
Formula not working when letter A is used in a named range jimar Excel Discussion (Misc queries) 7 July 6th 06 11:43 AM
Create named range Robert[_16_] Excel Programming 2 October 27th 03 11:57 PM


All times are GMT +1. The time now is 10:31 AM.

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

About Us

"It's about Microsoft Excel"