Hello - I am having a lot of trouble trying to get this line to work:
I have 3 columns and the following code looks for a value "B2" (through "B5") in row(3) and then inserts a blank row on the first instance each is found. It works for the most part, except for the CountA function:
I need the code to properly find the empty row so I can insert more code based on the empty row. By inserting message boxes I was able to determine that the code does not work.
Can anybody help?
Thanks for your help - Jim A
Code:
If WorksheetFunction.CountA(bFind) = 0 Then Goto a:
I have 3 columns and the following code looks for a value "B2" (through "B5") in row(3) and then inserts a blank row on the first instance each is found. It works for the most part, except for the CountA function:
Code:
Sub Insert_Blank_Rows()
Dim Lastrow, bFind As Range
Dim i As Integer
For i = 2 To 5
Lastrow = Cells(Rows.Count, 3).End(xlUp).Row
Set bFind = ActiveSheet.Range("C5:" & "C" & Lastrow).Find(What:="B" & i, LookIn:=xlValues, LookAt:=xlPart)
If bFind Is Nothing Then GoTo a:
[SIZE=2][B]If WorksheetFunction.CountA(bFind) = 0 Then Goto a:[/B][/SIZE]
''''If bFind = "" Then GoTo a: (this doesn't work either)
bFind.EntireRow.Insert shift:=xlUp ' inserts row
Rows(bFind.Row - 1).RowHeight = 9 ' sets row height
a:
Next i
End Sub
Can anybody help?
Thanks for your help - Jim A