Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Selecting Columns by Title

I am writing a macro to select columns based on their title.

If I always wanted to select Column D, then I could use:
Columns("D:D").Select

But in my case, I want to select a column that is titled "RC". I tried to
replace "D:D" with "RC", but I get an error.

Thanks,
Jessica
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 303
Default Selecting Columns by Title

You could name the columns. <Insert<name<add
for instance RCcolumn refers to D:D
and then use the line

Application.Goto Reference:="RCcolumn"


--
Greetings from New Zealand
Bill K
"Jessica" wrote in message
...
I am writing a macro to select columns based on their title.

If I always wanted to select Column D, then I could use:
Columns("D:D").Select

But in my case, I want to select a column that is titled "RC". I tried to
replace "D:D" with "RC", but I get an error.

Thanks,
Jessica



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Selecting Columns by Title

Does that mean you have the RC characters in a cell in row 1 and want to select
that column?

Option Explicit
Sub testme()
Dim FoundCell As Range
Dim WhatToFind As String

WhatToFind = "RC"

With Worksheets("Sheet1")
With .Rows(1)
Set FoundCell = .Cells.Find(What:=WhatToFind, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=True)
End With
End With

If FoundCell Is Nothing Then
MsgBox "No " & WhatToFind & " found in row 1"
Exit Sub
End If

FoundCell.EntireColumn.Select

End Sub


Jessica wrote:

I am writing a macro to select columns based on their title.

If I always wanted to select Column D, then I could use:
Columns("D:D").Select

But in my case, I want to select a column that is titled "RC". I tried to
replace "D:D" with "RC", but I get an error.

Thanks,
Jessica


--

Dave Peterson
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
Can I title columns with out them having a row number? Debi.Scbs Excel Discussion (Misc queries) 1 February 4th 10 06:50 PM
Need title separated into 2 columns Roberta Excel Discussion (Misc queries) 1 May 18th 09 09:15 PM
How do I title columns in excel? kaiserkreations Setting up and Configuration of Excel 1 January 12th 06 10:32 PM
columns title gdoguez Excel Discussion (Misc queries) 2 January 27th 05 08:45 PM
how do i title columns lawdogg New Users to Excel 2 January 26th 05 01:16 AM


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