Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can I title columns with out them having a row number? | Excel Discussion (Misc queries) | |||
Need title separated into 2 columns | Excel Discussion (Misc queries) | |||
How do I title columns in excel? | Setting up and Configuration of Excel | |||
columns title | Excel Discussion (Misc queries) | |||
how do i title columns | New Users to Excel |