Hello VBAExpress,
I have a column "G" with 2 sections of data and rows that are associated. with a header row. in the first column "A" is an item number
typically row 2 to 19 has HAR, row 20 to 39 has HAR-QC,
but the actual number of rows of HAR can change.
I have a macro that sorts the data to this stage every morning.
I insert a formula in the top section that pulls numbers from the bottom,
but if the values don't match the formula throws an error.
I'm looking for a way to count the occurrences of HAR down from row 2 till it ends, then look at the occurence of HAR-QC and add the missing items numbers in the same number row down that it would be in the HAR section.
I have this so far to count the occurrences, but not sure how to implement the look for a macth of the item number and insert if not present
[VBA]
Sub countHAR()
Dim i As Integer
Dim cHAR As Integer
i = 0
cHAR = 0
For i = 2 To 50
If Cells(i, 7).Value = "HAR" Then
cHAR = cHAR + 1
End If
Next i
'MsgBox Str(cHAR) & " HAR rows"
End Sub
Sub countHARQC()
Dim i As Integer
Dim cHARQC As Integer
i = 0
cHARQC = 0
For i = 2 To 50
If Cells(i, 7).Value = "HAR-QC" Then
cHARQC = cHARQC + 1
End If
Next i
'MsgBox Str(cHARQC) & " HAR-QC rows"
End Sub
[/VBA]
attached is the file im working on so far.
I 'll attach a sample of the raw data next.
Thank you in advance.
mp