insert a row according a condition

R

Raul Rodriguez

Hello everybody,

I need to insert a blank row above each row that
has "PARAM_TYPE" as data on a single row as shown below:

NAME = ""_AppsCollect"", PARAM_TYPE = COLLECTOR
NAME = ""APPServerStatus"", PARAM_TYPE = CONSUMER
NAME = ""BORDER"", ...
NAME = ""LogIncreaseRate"", PARAM_TYPE = STANDARD

and I found the following macro that does something
similar, but this search for the word "Total" in column 1
and inserts a blank row after the match of "Total.

' insert a row after each row which contains "Total" in
column 1
Dim rCell As Range
For Each rCell In ActiveSheet.UsedRange.Columns(1).Cells
If rCell.Value = "Total" Then rCell.Offset
(1).EntireRow.Insert
Next rCell

Does anyone can tell me what do I need to modify in order
to do what I mentioned at the beginning.

Regards.

Raul Rodriguez.
 
T

Tom Ogilvy

Sub InsertRows()
Dim rng as Range
set rng = cells(rows.count,1).End(xlup)
for i = rng.row to 1 step -1
if Application.Countif(cells(i,1).EntireRow,"*PARAM_TYPE*") > 0 then
cells(i,1).EntireRow.Insert
end if
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top