Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default insert a row according a condition

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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default insert a row according a condition

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_T YPE*") 0 then
cells(i,1).EntireRow.Insert
end if
Next
End Sub

--
Regards,
Tom Ogilvy


"Raul Rodriguez" wrote in message
...
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.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert a date that does not update if a condition is true FirstVette52 Excel Worksheet Functions 9 December 30th 08 09:25 PM
Insert rows with condition using macro Shazza Excel Discussion (Misc queries) 6 September 5th 08 12:06 AM
lookup with multiple condition, but one condition to satisfy is en Eddy Stan Excel Worksheet Functions 2 October 27th 07 02:06 PM
insert a line on condition jinvictor Excel Discussion (Misc queries) 1 June 4th 06 12:04 PM
Insert row if condition met Acct Supr - DCTC Excel Discussion (Misc queries) 1 October 6th 05 06:59 PM


All times are GMT +1. The time now is 11:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"