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

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
49,413
Office Version
  1. 365
Platform
  1. Windows
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.
 

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,454
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?
 

Pfeif0

New Member
Joined
Jun 13, 2006
Messages
14
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
 

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,454
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'.
 

Forum statistics

Threads
1,136,305
Messages
5,674,984
Members
419,540
Latest member
Nereus A

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
Top