Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 71
Default Referrring to cells by their column header

You can use Find. For instance, the following sets the value of the sixth
cell in the column on the active worksheet whose header (in the first row)
is "abc" to "P".

Rows(1).Find("abc").EntireColumn.Rows(6).Value = "P"

Or set a reference to the column to use later, but check to see if found

Dim rng as Range
On Error Resume Next
Set rng = Rows(1).Find("abc").EntireColumn
If rng is Nothing then 'range not found
'do something
Else
'do something else
rng.Rows(6).Value = "P"
End If
On Error Goto 0

Bob

"Fred Smith" wrote in message
...
I'm working with an export file that contains several columns each headed

by
a description. However, there's no guarantee what order the columns will

be
in.

In VBA, is there a way I can refer to a cell, and/or a column, by its
description (much like the sort function does)?

--
Thanks,
Fred
Please reply to newsgroup, not e-mail





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
Average cells based on column header Annabelle[_2_] Excel Discussion (Misc queries) 6 April 6th 11 09:57 PM
Retriving column header for non empty cells in a row Sushil Patil Excel Worksheet Functions 2 January 15th 10 03:41 PM
Return column number from column header text Roger[_3_] Excel Discussion (Misc queries) 4 February 14th 08 09:40 PM
Get Intersection value given column header and row header Scorcel Excel Discussion (Misc queries) 1 June 6th 07 08:24 AM
Split cells below header column: HBH Gloria Excel Worksheet Functions 2 March 9th 06 01:01 PM


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