Insert IF-formula in cell

Hagi

New Member
Joined
Jun 11, 2010
Messages
2
I am trying to write a VBA-Script that will fill write the following formula:
=IF(F9="";A8;A8+1)
into a given range of cells in Excel 2007. I can get Excel to write any value of formula into the cells, but the IF-Condition. Here is the code I am using and returns error 400:

Public Sub fill_Down()

Dim my_range As Range

With Worksheets("Kostenmatrix")

Set my_range = .Range("A9:A200")
my_range.Formula = "=IF(F9="";A8;A8+1)"
End With

End Sub


Thanks in advance for any hints how to solve this issue!

Hagi
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
You need to double-up the " within the formula. Try

Code:
my_range.Formula = "=IF(F9="""";A8;A8+1)"
 
Upvote 0
You need to double-up the " within the formula. Try

Code:
my_range.Formula = "=IF(F9="""";A8;A8+1)"

I tried that. There still is an error "400"

edit: I believe the Problem is the = sign in the if condition...
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,906
Members
452,366
Latest member
TePunaBloke

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