alejandro1404
New Member
- Joined
- Feb 10, 2016
- Messages
- 2
Hi all,
I'm new in forums, so I apologize if I do something wrong.
I have a question about using VBA for setting a formula. I have to do this:
1-Save a result from a formula in the file "Macro" in a variable called "var"
2-In the file "model" save the formula in a variable called "pivote"
3-Set a new formula as 'Pivote & "*" & var' in a cell in the file "model departamento"
For example:
1- The result is (var=)0,015
2- The formula is (pivote=)"=4000*20"
3- The formula I want to set is "=4000*20*0.015"
The problem I have in here is that there is an error, because (I think) the result of 'var' uses a 'comma' as a decimal and Excel uses a 'dot'. So when I run this code there shows the error 1004.
I really appreciate your help. Here is the code I'using:
PD: If you know a better code or a better way to do it, please tell me.
Thanks a lot
alejandro1404
I'm new in forums, so I apologize if I do something wrong.
I have a question about using VBA for setting a formula. I have to do this:
1-Save a result from a formula in the file "Macro" in a variable called "var"
2-In the file "model" save the formula in a variable called "pivote"
3-Set a new formula as 'Pivote & "*" & var' in a cell in the file "model departamento"
For example:
1- The result is (var=)0,015
2- The formula is (pivote=)"=4000*20"
3- The formula I want to set is "=4000*20*0.015"
The problem I have in here is that there is an error, because (I think) the result of 'var' uses a 'comma' as a decimal and Excel uses a 'dot'. So when I run this code there shows the error 1004.
I really appreciate your help. Here is the code I'using:
PD: If you know a better code or a better way to do it, please tell me.
Thanks a lot
alejandro1404
Code:
Windows("macro.xlsx").Activate
var = Range(Cells(cont_dep, 28), Cells(cont_dep, 28)).Value
Windows("model.xlsx").Activate
Pivote = Range(Cells(119, 6), Cells(119, 6)).Formula
Windows("model " & departamento & ".xlsx").Activate
Range(Cells(119, 6), Cells(119, 6)).Select
ActiveCell.Formula = Pivote & "*" & var