ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I go to a value (https://www.excelbanter.com/excel-programming/298727-how-do-i-go-value.html)

atoth22

How do I go to a value
 
I have a value in a cell. I want my file to find what cell in another
column contains that value. How do I do that? I want it to save the row
number in a variable, so I can know what row it is in. Thanks


---
Message posted from http://www.ExcelForum.com/


Don Guillett[_4_]

How do I go to a value
 
From vba help index

FindNext Method
See Also Applies To Example Specifics
Continues a search that was begun with the Find method. Finds the next cell
that matches those same conditions and returns a Range object that
represents that cell. Doesn't affect the selection or the active cell.

expression.FindNext(After)

expression Required. An expression that returns a Range object.

After Optional Variant. The cell after which you want to search. This
corresponds to the position of the active cell when a search is done from
the user interface. Note that After must be a single cell in the range.
Remember that the search begins after this cell; the specified cell isn't
searched until the method wraps back around to this cell. If this argument
isn't specified, the search starts after the cell in the upper-left corner
of the range.

Remarks
When the search reaches the end of the specified search range, it wraps
around to the beginning of the range. To stop a search when this wraparound
occurs, save the address of the first found cell, and then test each
successive found-cell address against this saved address.

Example
This example finds all cells in the range A1:A500 that contain the value 2
and changes their values to 5.

With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = 5
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
--
Don Guillett
SalesAid Software

"atoth22 " wrote in message
...
I have a value in a cell. I want my file to find what cell in another
column contains that value. How do I do that? I want it to save the row
number in a variable, so I can know what row it is in. Thanks


---
Message posted from
http://www.ExcelForum.com/





All times are GMT +1. The time now is 06:11 PM.

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