• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 342
  • Last Modified:

Find cell with specific word

can someone out there provide me with a bit of code that will find a specific word in colomn A in Excel. [lets say word is Reporting] so it needs tocover both upper and lowercase.

Thank you
0
Jagwarman
Asked:
Jagwarman
  • 3
  • 2
  • 2
  • +4
1 Solution
 
R_EdwardsCommented:
0
 
JagwarmanAuthor Commented:
Thanks R_Edwards but I need it to be VBA as it is part of a macro.
0
 
RobZimmermanCommented:
In excel's "home" tab locate the "Find and Select" all the way to the right of the window then run a search for 'Records'

Make sure the entire column A is selected

Hope this helps.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
helpfinderIT ConsultantCommented:
to find and select you can use:
 With Selection.Find
    .Forward = True
    .Wrap = wdFindStop
    .Text = "Hello"
    .Execute
End With

Open in new window

0
 
Saqib Husain, SyedEngineerCommented:
Range("A:A").Find("reporting", , xlValues, xlWhole, , , False).Select
0
 
JagwarmanAuthor Commented:
Thanks RobZimmerman but I am looking for some VBA code
0
 
Martin LissRetired ProgrammerCommented:
No selection required and highlights the word(s if more than one).

Sub FindWord()
    Dim lngLastRow As Long
    Dim lngIndex As Long
    
    lngLastRow = Range("A65536").End(xlUp).Row
    
    For lngIndex = 1 To lngLastRow
        If Cells(lngIndex, 1) = "test" Then ' change to suit
            Cells(lngIndex, 1).Select
            With Selection.Interior
                .Pattern = xlSolid
                .PatternColorIndex = xlAutomatic
                .Color = vbYellow
                .TintAndShade = 0
                .PatternTintAndShade = 0
            End With
        End If
    Next
End Sub

Open in new window

0
 
JagwarmanAuthor Commented:
Just to clarify, when the VBA finds the cell I need the macro to 'Select' the cell i.e. I need to end up on that cell

Thanks
0
 
Martin LissRetired ProgrammerCommented:
Sub FindWord()
    Dim lngLastRow As Long
    Dim lngIndex As Long
   
    lngLastRow = Range("A65536").End(xlUp).Row
   
    For lngIndex = 1 To lngLastRow
        If Cells(lngIndex, 1) = "test" Then ' change to suit
            Cells(lngIndex, 1).Select
            Exit Sub
        End If
    Next
End Sub
0
 
SteveCommented:
You could use this one line:

ActiveSheet.Range("A:A").Find(What:="Reporting", After:=Range("A1"), LookIn:=xlFormulas, _
        LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

Open in new window



or if you want to select ALL cells this may do it...

Sub Macro1()
Dim rng As Range, cell As Range, hid As Range
Set rng = ActiveSheet.Range("A1:A5000")
For Each cell In rng
If UCase((cell.Value)) Like "*REPORTING*" Then
If hid Is Nothing Then
Set hid = cell
Else: Set hid = Union(hid, cell)
End If
End If
Next cell
On Error Resume Next
hid.Select
End Sub

Open in new window

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now