I need to count the qty of "Rainguards" in a bunch of excel files, and add a row with these values as shown below (qty is in Column C):
Value in column D in the new row changes based on values in column K, and another value in N, see below:
see code below, any help is appreciated
Value in column D in the new row changes based on values in column K, and another value in N, see below:
see code below, any help is appreciated
VBA Code:
Public c As Range
Public lr6 As Long
Public lr3 As Long
Public i As Long
Sub Rainguards()
lr6 = lr3 + 1 ' set lr6 to one row below lr2, which is the total number of eyebolts and chains
Set c = Range("C" & lr6) ' use this cell as our starting point
With c
.Offset(, -2).Value = .Offset(-1, -2).Value
.FormulaR1C1 = "=COUNTIF(R2C11:R" & lr2 & "C11,""Rainguards"")"
.Value = .Value
.Offset(, -1).Value = "!"
.Offset(, 6).Value = "Purchased"
.Offset(, 8).Value = "Rainguard"
If Range("K" & (Range("i", 7).Value)).Value Like "*170**580*" Then
.Offset(, 1).Value = "F89997"
ElseIf Range("K" & i7).Value Like "*170**580*" Then
.Offset(, 1).Value = "F89998"
ElseIf Range("K" & i7).Value Like "*170**580*" And _
Range("N" & i10).Value Like "*Hernando*" Then
.Offset(, 1).Value = "F89998U"
ElseIf Range("K" & i7).Value Like "*225**440*" Then
.Offset(, 1).Value = "F89999"
ElseIf Range("K" & i7).Value Like "*667*" Then
.Offset(, 1).Value = "F90003"
End If
.EntireRow.Font.Bold = True
End With
If ws1.Range("C" & i7).Value Like "*0*" Then
ws1.Rows(lr6).Delete
End If
End Sub