LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 55
Default Adding Named ranged for each column...

Im trying to look through a header row and for each column after a
certain point (the first few columns do not require analysis), assign
named ranges to the column data using the first row as the name. I want
to do this for all the remaining columns. I have three problems in my
code. Three, that I can see that is 

At the line - For Each c In Selection, I think I should use For Each
c In Selection however, I receive the error: error 13 type mismatch

At the line - For Each c In Selection I expect the following code
to act on each cell in the selection, in sequence however, it
happens to the entire selection

Using the macro recorder I came up with
ActiveSheet.Names.Add Name:="DC_RES", RefersToR1C1:="=R1C7:R7C7"

Ive tweaked that to:
ActiveSheet.Names.Add Name:=c.Value, refersto c.address

But I dont have a handle on the refers to Property

My code is:

Public Sub CreateNames()

Dim c
Dim srchRow


'designate header range
Range("a1").Select

Range(Selection, Selection.End(xlToRight)).Select

srchRow = Selection.Find(what:="DC_RES", After:=ActiveCell,
LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByColumns,
SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Select

srchRow = Range(Selection,
Selection.End(xlToRight)).Select

For Each c In Selection 'srchRow causes an error!


ActiveSheet.Names.Add Name:=c.Value, refersto c.address

Next

End Sub

any help will be appreciated
Robert

 
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
Automatically Adding Time based on a name ranged Cathy Excel Discussion (Misc queries) 1 February 27th 08 02:13 AM
Named ranged selection problem Martin B Excel Worksheet Functions 3 January 4th 08 09:32 PM
Changing a named ranged based on array size on a form Wanderer[_2_] Excel Programming 2 June 27th 06 01:10 PM
Ranges, adding a column to a named print range then saving the file [email protected] Excel Programming 1 April 27th 06 01:42 AM
Vlookup - Using a named ranged for col_index_num [email protected] Excel Discussion (Misc queries) 2 June 1st 05 05:38 PM


All times are GMT +1. The time now is 06:16 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"