I have this code that counts the qty of a certain item, adds a row at the end of the excel file to show the qty
If the total qty adds up to 0, the code removes this new row, what if I just want to remove the value in column D in the new row instead of removing the entire row when the value is 0?
If the total qty adds up to 0, the code removes this new row, what if I just want to remove the value in column D in the new row instead of removing the entire row when the value is 0?
VBA Code:
Public lr2 As Long
Public c As Range
Public lr As Long
Sub EyeboltsAndChains()
'Sum up the # of eyebolt & chains
lr2 = lr + 1 ' set lr2 to one row below the current lr row
Set c = ws1.Range("C" & lr2) ' use this cell as our starting point
With c
.Offset(, -2).Value = .Offset(-1, -2).Value 'ADD ADDITIONAL ROW
.FormulaR1C1 = "=COUNTIF(R2C11:R" & lr & "C11,""CHAIN & EYEBOLT"")" 'COUNT THE TOTAL NUMBER OF EYEBOLT & CHAINS, SHOW THEM ON THE NEW ROW
.Value = .Value
.Offset(, -1).Value = "!"
.Offset(, 1).Value = "F09720"
.Offset(, 6).Value = "Purchased"
.Offset(, 8).Value = "CHAIN & EYEBOLT"
.EntireRow.Font.Bold = True
End With
If ws1.Range("C" & i3).Value Like "*0*" Then
ws1.Rows(lr2).Delete
End If
End Sub