I have this code that add up all the "CHAIN & EYEBOLT" in a entire excel file, count the quantity, and add a row to the end of the excel file with the quantity.
This code is used on thousands of excel files.
Sometimes some of these files contain 0 eyebolt & chain, for these, I do not want an additional row to be added. I am thinking there are 2 options:
1. modify this code so when the count is 0, no row is added.
2. modify this code so a row is added even if the qty is 0, but when it is 0, this row gets removed
Below is what I have so far, any pointers would be greatly appreciated !
This code is used on thousands of excel files.
Sometimes some of these files contain 0 eyebolt & chain, for these, I do not want an additional row to be added. I am thinking there are 2 options:
1. modify this code so when the count is 0, no row is added.
2. modify this code so a row is added even if the qty is 0, but when it is 0, this row gets removed
Below is what I have so far, any pointers would be greatly appreciated !
VBA Code:
Public c As Range
Public lr As Long, lr2 As Long
Sub EyeboltsAndChains()
lr2 = lr + 1
Set c = ws1.Range("C" & lr2)
With c
.Offset(, -2).Value = .Offset(-1, -2).Value
.FormulaR1C1 = "=COUNTIF(R2C11:R" & lr & "C11,""CHAIN & EYEBOLT"")"
.Value = .Value
.Offset(, -1).Value = "!"
.Offset(, 1).Value = "F09720"
.Offset(, 6).Value = "Purchased"
.Offset(, 8).Value = "CHAIN & EYEBOLT"
.EntireRow.Font.Bold = True
End With
End Sub