Solved

Find cell with specific word

Posted on 2013-01-18
11
335 Views
Last Modified: 2013-01-18
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
Comment
Question by:Jagwarman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +4
11 Comments
 
LVL 8

Expert Comment

by:R_Edwards
ID: 38793311
0
 

Author Comment

by:Jagwarman
ID: 38793330
Thanks R_Edwards but I need it to be VBA as it is part of a macro.
0
 
LVL 3

Expert Comment

by:RobZimmerman
ID: 38793351
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 19

Expert Comment

by:helpfinder
ID: 38793356
to find and select you can use:
 With Selection.Find
    .Forward = True
    .Wrap = wdFindStop
    .Text = "Hello"
    .Execute
End With

Open in new window

0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 38793423
Range("A:A").Find("reporting", , xlValues, xlWhole, , , False).Select
0
 

Author Comment

by:Jagwarman
ID: 38793426
Thanks RobZimmerman but I am looking for some VBA code
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 38793427
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
 

Author Comment

by:Jagwarman
ID: 38793483
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
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
ID: 38793494
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 38793496
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
 
LVL 24

Expert Comment

by:Steve
ID: 38793624
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question