Get cell ref for the value which is visible

ExcelMaker007

New Member
Joined
Jul 14, 2020
Messages
31
Hi,

I have a value Ex: Puppy word, I will be available all over the excel, but some column and rows be hidden which may also have puppy in it...

Now I need to get the cell reference of word puppy from the visible cells only....

Please help me with vba code
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Amend line
VBA Code:
Set r = ActiveSheet.Range("A2:H11").SpecialCells(xlCellTypeVisible)
for your range address:
VBA Code:
Sub EM()

Dim c As Range, r As Range, fc As String

    Set r = ActiveSheet.Range("A2:H11").SpecialCells(xlCellTypeVisible)
    
    With r
        Set c = .Find("puppy", , xlValues, , , , 0)
        If Not c Is Nothing Then
            fc = c.Address
            Do
                Set c = .FindNext(c)
                MsgBox c.Address
                If c Is Nothing Then Exit Do
        Loop While c.Address <> fc
        End If
    End With

End Sub
 
Upvote 0
I need to loopup for that word to set the range to process my next step, that is coloring the column ....

so if I get the cell reference EX: B35, It will be useful to do it
 
Upvote 0
Replace the line
VBA Code:
MsgBox c.Address
with
VBA Code:
c.EntireColumn.InteriorColor = vbRed
 
Upvote 0

Forum statistics

Threads
1,215,063
Messages
6,122,928
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top