IF formula in VBA

ZionX

New Member
Joined
Mar 17, 2011
Messages
11
Good morning everyone, can some one please help me convert this IF formula to vba type?

Code:
=IF(I14="PCBA","",IF(AB14=M14,"",(AB14-M14)*K14))

this is the code i made, but cant work, hope some one can help me up, thanks so much.
Code:
Dim IngRows As Long
Dim Rng As Range
IngRows = .Range("G1").CurrentRegion.Rows.count

Set Rng = .Range(Cells(2, 30), Cells(IngRows, 30))
    Rng.Value = "=IF(" & .Range(Cells(2, 9), Cells(IngRows, 9)) & "=""PCBA"","""",IF(" & .Range(Cells(2, 28), Cells(IngRows, 28)) & "=" & .Range(Cells(2, 13), Cells(IngRows, 13)) & ","""",(" & .Range(Cells(2, 28), Cells(IngRows, 28)) & "-" & .Range(Cells(2, 13), Cells(IngRows, 13)) & ")*" & .Range(Cells(2, 11), Cells(IngRows, 11)) & "))"
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Try for the last line

Code:
Rng.FormulaR1C1="=IF(RC9=""PCBA"","""",IF(RC28=RC13,"""",(RC28-RC13)*RC11))"

Not tested so please back up file before trying!
 
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,909
Members
452,949
Latest member
beartooth91

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