row column return

nascarjeff

New Member
Joined
Jan 19, 2004
Messages
10
I am trying to do a search for specific text. That part seems to work in the code below. What i would like to also return is the row & column where the info was found.
Thanks in Advance,
Jeff

Dim FindSelection as Variant
Dim SearchArray as Variant

SearchArray = Selection.value
For Each FindSelection In SearchArray
If Label1 = FindSelection Then 'Label1 = user selection from a list box
MsgBox "Found it"
End If
Next
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Actually, you can get that MUCH easier, using the .Find method... something like this (untested)

Code:
Sub SearchIt()
    Dim Rng As Range
    On Error Resume Next
    Set Rng = Selection.Find(Label1)
    If Not Rng Is Nothing Then
        MsgBox "Row: " & Rng.Row & ", Column: " & Rng.Column
    End If
End Sub
 
Upvote 0
That Works !
Thanks for the tip. VB is a nice enviroment to write code. I just wish there was a handy manual for all of the additional commands, methods etc that you can do in Excel.
Thanks Again
Jeff (y)
 
Upvote 0
Online help is a great resource. It just reading "Microsoft-ese" that confuses me sometimes. I have only been using VB for about a year or so now, so i guess i am still in the new-bie category too.
 
Upvote 0

Forum statistics

Threads
1,213,521
Messages
6,114,104
Members
448,548
Latest member
harryls

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