• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Find a text and select the column

vijehspaul

Member
Hi,
Below is my situation:
Want to look for a word (text) and once find, i need to select the column.

When searched on net, i got find function help.
Code is below:
Code:
With Worksheets(1).Range("a1:aa1")
Set c = .Find("text to find", lookin:=xlValues)
If Not c Is Nothing Then
address = c.Address
Else
MsgBox "Nothing to find"
End If
End With
It gives me the cell address ( eg: $K$1)
I need to select the entire column. in this case column K

Please help
 
Got a solution.
I modified the code as
Code:
Dim address as Range
With Worksheets(1).Range("a1:aa1")
Set c = .Find("text to find", lookin:=xlValues)
If Not c Is Nothing Then
address = c.Address
c.EntireColumn.Select
Else
MsgBox "Nothing to find"
End If
End With

Share if there is a better way..
Thanks
 
Hi vijeshspaul

Add the following

Code:
Columns(c.Column).EntireColumn.Select

Although why are you selecting anything? What are you trying to do?

Take care

Smallman
 
Back
Top