formulas in VBA instead of inside the cells

jigglypuff

New Member
Joined
Mar 28, 2013
Messages
25
Hi guys, how can I use a formula via VBA instead of putting it in the cell itself? It is causing me problems because when I put a formula in a entire row, all the cells five me the number ZERO, when I want them to stay without any number until I input something in the other row's cell in the same line. I will give an example: I would like that anytime I entry any number in a cell in column A the cell in column C will give me the number in column A times the number in column B (which is a variable daily updated via an internet connection), and when the cell in column A becomes "null" (that is when there is no number in the cell, not even a zero) the cell in column C also becomes null.

When I try to do it using formulas in the cells I always get a ZERO in all the column cause they read a 'null' as a 'zero'. Trying it using VBA I have some success but still have problems. I tried this code

If Target.Column = 3 Then Cells(Target.Row, 8) = Cells(Target.Row, 3) * Worksheets("Sheet4").Range("d32").Value


But it makes the cell in column 8 be static and change only when I click on the cell in column 3. I need it to change automatically when the number in D32 is changed too. As a formula in the cell would do.

Any ideas? is there any way to input a formula via VBA, how?
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

konew1

Well-known Member
Joined
Oct 17, 2007
Messages
2,288
Put the formula in the first row where you want the calculation, and copy it down. If the cell on that row in column A is null then the cell in column C will contain the formula but will return null. That is, column C will appear empty until you load data into A
 
Upvote 0

Forum statistics

Threads
1,195,858
Messages
6,011,979
Members
441,661
Latest member
Pammie007

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