ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VBA Cell Address (https://www.excelbanter.com/excel-discussion-misc-queries/106660-vba-cell-address.html)

scottfoxall

VBA Cell Address
 
I run a macro to find a value/text in a spread sheet. Instead of getting the
value from that cell, I want the address. Is there code that can do this?

PCLIVE

VBA Cell Address
 
instead of .value, use .address


"scottfoxall" wrote in message
...
I run a macro to find a value/text in a spread sheet. Instead of getting
the
value from that cell, I want the address. Is there code that can do this?




Dave

VBA Cell Address
 
This code looks for the string "asdf" in the current worksheet and
displays a message box with the address when it is found. If the
string is not found it advises the user, as well. You can substitute
your search string as a variable or as a hardcoded entry.

Sub Find()
On Error GoTo NotFound:
Cells.Find(What:="asdf", After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate

MsgBox ActiveCell.Address
End

NotFound:
MsgBox ("Search target not found.")

End Sub


scottfoxall

VBA Cell Address
 
Thankyou. & rated

"PCLIVE" wrote:

instead of .value, use .address


"scottfoxall" wrote in message
...
I run a macro to find a value/text in a spread sheet. Instead of getting
the
value from that cell, I want the address. Is there code that can do this?






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

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