Does anybody know ho to assign a cell to a variable?

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Does anybody know ho to assign a cell to a variable in excel?
Like this?
MyVariable = Range("A1").Value

If not, you might like to spell out in more detail what you are trying to do.
 
Upvote 0
Do you mean assign the value of a cell to the variable, or the address
of the cell?

To assign the cell's value, something like this:
Code:
Dim Var As String
Var = [A1].Value
MsgBox Var

To assign the cell's address...
Code:
Dim Var As String
Var = [A1].Address
MsgBox Var

If this isn't what you mean then can you explain in more detail?
 
Upvote 0
Is there a way to do it not using some sort of macro formula? I'm not familiar with them but was hoping I could use a basic function. Lets say I have a cell that is constantly changing due to random # generation when I pres F9...I want that variable to record what the new # has become so I can manipulate it.
Thanks,
Keith
 
Upvote 0
Is there a way to do it not using some sort of macro formula?
As far as I know (providing I understand what you're looking to do), no.
I believe you're going to need some vba.

You might be able to do it with worksheet functions though if you just refer to
the cell in question in your formula(s)

I guess it all depends on your use of the term 'variable'.
 
Upvote 0

Forum statistics

Threads
1,216,309
Messages
6,129,997
Members
449,551
Latest member
MJS_53

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top