Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Please help...

I have a problem. How to insert a row below a cell that contains a
given sign? For example, I need to insert a new row below every cell
that contains x? X is in in every row in column A.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 85
Default Please help...

Assumes your data starts at row 1.
Change the limits of r to suit your requirement. Note that, as the code adds
a blank line after each X, this row range will have to be at least double
the original row range.
Note that X is case specific.

Sub test()
' Lower value for r should be first data row + 1
' Upper value = lower value + number of original rows
For r = 2 To 20
' X is case specific
If Cells(r - 1, 1).Value = "X" Then
Cells(r, 1).EntireRow.Insert
End If
Next
End Sub

Ian
wrote in message
...
I have a problem. How to insert a row below a cell that contains a
given sign? For example, I need to insert a new row below every cell
that contains x? X is in in every row in column A.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 695
Default Please help...

Sub insetRows()

Set sh = Sheets("Sheet1")
rw = sh.Cells(65500, 1).End(xlUp).Row

For c = rw To 1 Step -1
If sh.Cells(c, 1) = "X" Then sh.Cells(c, 1).EntireRow.Insert
Next

End Sub


" skrev:

I have a problem. How to insert a row below a cell that contains a
given sign? For example, I need to insert a new row below every cell
that contains x? X is in in every row in column A.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Please help...

To avoid errors if case sensitive:

Sub rwInsrt()
lr = Cells(Rows.Count, 1).End(xlUp).Row
For i = lr To 2 Step -1
If LCase(Cells(i, 1)) = "x" Then
Cells(i, 1).EntireRow.Insert
End If
Next
End Sub


" wrote:

I have a problem. How to insert a row below a cell that contains a
given sign? For example, I need to insert a new row below every cell
that contains x? X is in in every row in column A.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 220
Default Please help...

I think he meant:

Cells(i + 1, 1).EntireRow.Insert

--
Dan

On Jan 3, 7:46*am, wrote:
I have a problem. How to insert a row below a cell that contains a
given sign? For example, I need to insert a new row below every cell
that contains x? X is in in every row in column A.



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



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

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

About Us

"It's about Microsoft Excel"