locate cell with specific text and select that column

  • Thread starter Thread starter rockytopfan4ever
  • Start date Start date
R

rockytopfan4ever

I need a macro that will search for a cell with specific text within a row
and then select its appropriate column. Any ideas?
 
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!!
 
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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top