ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find cell contents within a data matrix (https://www.excelbanter.com/excel-programming/397746-find-cell-contents-within-data-matrix.html)

[email protected]

Find cell contents within a data matrix
 
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.


Tom Ogilvy

Find cell contents within a data matrix
 
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

--
Regards,
Tom Ogilvy


" wrote:

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.




All times are GMT +1. The time now is 07:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com