Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default How to select a range based on what's in the row header?

I would like my macro to look for the word "Date" and then create a
range called "Date_Column", rather than hard-coding it that Date will
always be column B, column D, etc. Any suggestions or pointers to
tutorials?

Thanks,
Rachel
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default How to select a range based on what's in the row header?


Uzytkownik "Rachel Garrett" napisal w wiadomosci
...
I would like my macro to look for the word "Date" and then create a
range called "Date_Column", rather than hard-coding it that Date will
always be column B, column D, etc. Any suggestions or pointers to
tutorials?

Thanks,
Rachel


u can try with
Sub add_name()
Column = ActiveSheet.Rows(1).Find(What:="Date").Column
ActiveWorkbook.Names.Add Name:="Date_Column", RefersToR1C1:=Cells(1,
Column)' i assume it is row 1
End Sub

mcg


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default How to select a range based on what's in the row header?

Sub date_finder()
For Each r In ActiveSheet.UsedRange
If r.Value = "Date" Then
Set Date_Column = Columns(r.Column)
Exit For
End If
Next
End Sub

--
Gary''s Student - gsnu200795


"Rachel Garrett" wrote:

I would like my macro to look for the word "Date" and then create a
range called "Date_Column", rather than hard-coding it that Date will
always be column B, column D, etc. Any suggestions or pointers to
tutorials?

Thanks,
Rachel

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
vba - Select Used Range minus the top header Johnny[_11_] Excel Programming 5 April 21st 23 08:11 PM
Select sheets based on what is in a range. Steve Excel Programming 6 June 29th 06 06:12 PM
How can I select a range of cells for header? emil Excel Programming 2 June 11th 06 10:38 AM
How to select a range based on values in 1 column ForestRamsey Excel Programming 2 August 30th 05 05:00 PM
Can I select a range based on the cell's contents? [email protected] Excel Programming 1 July 29th 05 11:08 AM


All times are GMT +1. The time now is 09:39 PM.

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"