Forum Discussion
KAM_Mumin
Oct 22, 2022Brass Contributor
MS EXCEL VBA IF Formula.
Hi Everyone! I have a stock sheet with all models which I have already and now want to get some spcific models stock in a new sheet,,, I use =SUMPRODUCT(([@[Model No]]=RefModelsT[Model No])*RefMode...
- Oct 22, 2022
Do you want to sum in VBA only with IF THEN ELSE END IF statement without using a standard sum formula (SUMIF, SUMIFS, SUMPRODUCT)? If so i can't help you unfortunately.
OliverScheurich
Oct 22, 2022Gold Contributor
Sub MyMacro()
Dim Destws As Worksheet
Dim lastrow As Long
Set Destws = Worksheets("NewT")
lastrow = Destws.Cells(Destws.Rows.Count, "A").End(xlUp).Row
Destws.Range("C2:C" & lastrow).FormulaR1C1 = "=SUMPRODUCT(([@[Model No]]=RefModelsT[Model No])*RefModelsT[Onhand])"
End SubMaybe with these lines of code. In the attached file you can click the button in cell G2 to run the macro.
KAM_Mumin
Oct 22, 2022Brass Contributor
Bro yours is ok,,, but I want to do it by VBA IF function,,,if you can then Please
- OliverScheurichOct 22, 2022Gold Contributor
Do you want to sum in VBA only with IF THEN ELSE END IF statement without using a standard sum formula (SUMIF, SUMIFS, SUMPRODUCT)? If so i can't help you unfortunately.