Hy guys.. as the title says I am trying to build a macro that will help me copy the rows from one sheet in which there are values equal to the active cell and then insert those rows under the active cells row.
So far i got
Sub Find()
Dim Rng As Range
Dim val As Integer
With Sheets("AB").Range("B:B").Find(ActiveCell.Value)
'finds how many rows are with active cells value
val = Application.WorksheetFunction.CountIf(Sheets("AB").Range("B:B"), ActiveCell.Value)
'should get the range of those rows
Set Rng = Sheets("AB").Rows("5:10")
Rng.Copy
'inserts the copies rows
ActiveCell.Offset(val).Insert Shift:=xlDown
End With
End Sub
Any help will be much appreciated.
Bookmarks