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

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.

Juan Pablo González

MrExcel MVP
Joined
Feb 8, 2002
Messages
11,959
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
 

nascarjeff

New Member
Joined
Jan 19, 2004
Messages
10
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)
 

nascarjeff

New Member
Joined
Jan 19, 2004
Messages
10
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.
 
Learn Excel from Bill Jelen

Understanding data is crucial, and the easiest place to start is with Microsoft Excel.

Forum statistics

Threads
1,151,491
Messages
5,764,679
Members
425,229
Latest member
Rashid mahmood

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
Top