Oct 22 2022 07:38 AM - edited Oct 22 2022 09:26 AM
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])*RefModelsT[Onhand])
to get the value, now i want to do it with VBA IF formula,,, but when i use
Sub macro()
'
If range("NewT[@Model No]").value = range("RefModelsT[Model No]").value Then
What i want to do,,,, but error showing on the start of IF formula criteria ...
What i need to do if want to match this,,
Please any of you have solution then please reply,,,
I attach below some screenshot and a attach for understanding,,,
;)
Oct 22 2022 08:13 AM
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 Sub
Maybe with these lines of code. In the attached file you can click the button in cell G2 to run the macro.
Oct 22 2022 09:23 AM
Oct 22 2022 12:10 PM
SolutionDo 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.
Oct 22 2022 01:25 PM
Oct 22 2022 12:10 PM
SolutionDo 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.