Variables

Deepjuillet

New Member
Joined
May 21, 2022
Messages
1
Office Version
  1. 365
  2. 2013
Platform
  1. Windows
Hi I have an excel sheet that names a number of cells as variables. For example cell A1 is defined as speed and in formulas elsewhere in the workbook I have used speed in formulas rather than A1.

I now want to write a function in VBA that uses speed in a formula. Rather than referring to A1, I want to know if I can use the named variable (speed) in the module. When I wrote the code and ran debugger it showed no error but returned zero as result.

Is this possible? I can always to the calculations in the workbook itself but thought I’d try developing a function and use that instead.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
This is just a very simple example for cell A1 defined as speed, if you need a Function it wouldn't be much different.
VBA Code:
Sub test()
    Range("B1") = Range("speed") * 250
    Range("B2").FormulaR1C1 = "=speed*250"
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,731
Messages
6,180,611
Members
452,991
Latest member
JM_000888

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