ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   locate cell with specific text and select that column (https://www.excelbanter.com/excel-discussion-misc-queries/196869-locate-cell-specific-text-select-column.html)

rockytopfan4ever

locate cell with specific text and select that column
 
I need a macro that will search for a cell with specific text within a row
and then select its appropriate column. Any ideas?

Nayab

locate cell with specific text and select that column
 
On Jul 30, 5:35*pm, rockytopfan4ever
wrote:
I need a macro that will search for a cell with specific text within a row
and then select its appropriate column. *Any ideas?


There are lot of ideas. First one is: why can't you put some serious
stuff and do it yourself? U just need to record the steps and then
play with the code in the macro as per your needs!!

Don Guillett

locate cell with specific text and select that column
 
The macro recorder can be your friend. Recorded and cleaned up.

Sub Macro2()
'
' Macro2 Macro
' Macro recorded 7/30/2008 by Donald B. Guillett
'

'
Rows("1:1").Select
Selection.Find(What:="c", After:=ActiveCell, LookIn:=xlFormulas, LookAt
_
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
End Sub

Sub findandselect()
Rows(1).Find("c", After:=Cells(1, 1), _
LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext).Activate
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"rockytopfan4ever" wrote in
message ...
I need a macro that will search for a cell with specific text within a row
and then select its appropriate column. Any ideas?



Gary''s Student

locate cell with specific text and select that column
 
First click on a cell in the row you want searched and then run:

Sub get_col()
s = "happiness"
n = ActiveCell.Row
For i = 1 To Columns.Count
If Cells(n, i).Value = s Then
Cells(n, i).EntireColumn.Select
End If
Next
End Sub

to find happiness.
--
Gary''s Student - gsnu200796


All times are GMT +1. The time now is 11:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com