ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find variable in a sheet (https://www.excelbanter.com/excel-programming/417449-find-variable-sheet.html)

Sean Timmons

Find variable in a sheet
 
This cannot be hard. I don't know why I can't figure it out.

I am assigning a value to a variable based on a sheet named Rep and then I
want to find this value in another sheet, Map.

I tried using the Cells.Find(What:=VariableName, etc.) but it chokes on me.
I verified the variable is populated properly by using a message box. What is
the code to find a variable? Ack!

Jim Thomlinson

Find variable in a sheet
 
Generally speaking you want something like this...

Dim rngFound As Range

Set rngFound = Sheets("Maps").Cells.Find(What:=MyString, _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
MatchCase:=False)

If Not rngFound Is Nothing Then MsgBox rngFound.Address
--
HTH...

Jim Thomlinson


"Sean Timmons" wrote:

This cannot be hard. I don't know why I can't figure it out.

I am assigning a value to a variable based on a sheet named Rep and then I
want to find this value in another sheet, Map.

I tried using the Cells.Find(What:=VariableName, etc.) but it chokes on me.
I verified the variable is populated properly by using a message box. What is
the code to find a variable? Ack!


Sean Timmons

Find variable in a sheet
 
There it is! Thank you much! Knew I was thinking too hard!

"Jim Thomlinson" wrote:

Generally speaking you want something like this...

Dim rngFound As Range

Set rngFound = Sheets("Maps").Cells.Find(What:=MyString, _
LookAt:=xlPart, _
LookIn:=xlFormulas, _
MatchCase:=False)

If Not rngFound Is Nothing Then MsgBox rngFound.Address
--
HTH...

Jim Thomlinson


"Sean Timmons" wrote:

This cannot be hard. I don't know why I can't figure it out.

I am assigning a value to a variable based on a sheet named Rep and then I
want to find this value in another sheet, Map.

I tried using the Cells.Find(What:=VariableName, etc.) but it chokes on me.
I verified the variable is populated properly by using a message box. What is
the code to find a variable? Ack!



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

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