Find cell contents within a data matrix

V

vrzimmerm

I am trying to write a macro that will find and select the first
instance of a value that the user had previously inputted into a cell
(let's say it's on sheet 1 in cell A1) within column C of a large
data matrix, where the matrix has been named DATA. How can I do
this?

Many thanks.
 
G

Guest

Dim r as Range, r1 as Range, r2 as Range
Dim res as Variant
set r = worksheets("Data").Columns(3).Cells
set r1 = Worksheets("Sheet1").Range("A1")
res = Application.match(r,r1,0)
if not iserror(res) then
set r2 = r1(res)
msgbox "found at " & r2.Address(0,0,xlA1,True)
else
msgbox "Not found"
End if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top