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

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
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,214,861
Messages
6,121,971
Members
449,059
Latest member
oculus

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