I have this macro to calculate the gallonage of paint (CS55), it adds an additional row to the end of the excel file to display the gallonage
This part of the macro does the calculation. the "2" in the equation means two layers.
I need to modify the code so it can calculate the gallonage based on 1 layer or 2 layers.
1 layer (these all contain 1 letter B, which means black):
CS55 B/W
CS55 B/R/G (Black/red/gray)
CS55 B/G/R(Black/gray/red)
2 layers (these all contain 2 letter B):
CS55 B/W/B
CS55 B/R/B
CS55 B/G/B
CS55 Black (If it is a single color, then it is 2 layers)
full macro posted below for your reference
This part of the macro does the calculation. the "2" in the equation means two layers.
VBA Code:
.FormulaR1C1 = "=SUMIF(R2C11:R" & lr & "C11,""*CS55 Black*"",R2C3:R" & lr & "C3)"
.Value = .Value * 0.000666 * 7.48 * 2
I need to modify the code so it can calculate the gallonage based on 1 layer or 2 layers.
1 layer (these all contain 1 letter B, which means black):
CS55 B/W
CS55 B/R/G (Black/red/gray)
CS55 B/G/R(Black/gray/red)
2 layers (these all contain 2 letter B):
CS55 B/W/B
CS55 B/R/B
CS55 B/G/B
CS55 Black (If it is a single color, then it is 2 layers)
full macro posted below for your reference
VBA Code:
Sub PaintCS55()
Dim lrNew As Long
lrNew = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
With Range("C1", Cells(Rows.Count, "C").End(3))
.Replace What:=" sqFt", Replacement:=vbNullString, LookAt:=xlPart
End With
lrNew = lrNew + 1
Set c = ws1.Range("C" & lrNew)
With c
.Offset(, -2).Value = .Offset(-1, -2).Value
.FormulaR1C1 = "=SUMIF(R2C11:R" & lr & "C11,""*CS55 B*"",R2C3:R" & lr & "C3)"
.Value = .Value * 0.000666 * 7.48 * 2
.NumberFormat = "0"
.Offset(, -1).Value = "."
.Offset(, 1).Value = "F62655"
.Offset(, 6).Value = "Purchased"
.Offset(, 8).Value = "CS55 Black"
' .EntireRow.Font.Bold = True
End With
If Cells(lrNew, "C").Value Like 0 Then
Rows(lrNew).Delete
End If
End Sub