Variable into a Formula

aitor

New Member
Joined
Aug 16, 2011
Messages
3
I've been working for ages and I'm stuck with this problem.

I'm programming with visual basic excel and I simply want to write a formula where the variables change.

The formulae I want to program is =E16&D11&H19 where the numbers 16 and 19 are variables.

ActiveCell.Formula = "= " & "A" & y &" & "& "D11"&" & "&"D" & p & " "

I've been trying with the code above but it doesnt work out.

Anyhelp?
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Maybe something like:
Code:
Dim a As Long
Dim b As Long

'=E16&D11&H19

a = 16
b = 19

ActiveCell.Formula = "=E" & a & "&D11&H" & b
 
Upvote 0
Maybe something like:
Code:
Dim a As Long
Dim b As Long
 
'=E16&D11&H19
 
a = 16
b = 19
 
ActiveCell.Formula = "=E" & a & "&D11&H" & b


It worked out!!! thank u so much!! still dont understand why I dont need a " at the end of the expression though.

Cheers mate!
 
Upvote 0

Forum statistics

Threads
1,224,505
Messages
6,179,151
Members
452,891
Latest member
JUSTOUTOFMYREACH

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