ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Insert rows in depending on criteria in variable columns (https://www.excelbanter.com/excel-programming/312395-insert-rows-depending-criteria-variable-columns.html)

jeffbert

Insert rows in depending on criteria in variable columns
 
I would like to thank everyone in advance for looking into this for me.

I currently have a macro that inserts a blank row after every cell in column
A that changes. See below:

Tom
Tom
Tom
Dick
Dick
Harry
Harry
Harry

The macro would insert a row after the 3rd Tom, the 2nd Dick, and the third
Harry. I have come across the need to be able to pick which column I want the
macro to examine. Sometimes column A, sometimes AB, etc. Any suggestions?

Thanks again

Jeff








No Name

Insert rows in depending on criteria in variable columns
 
hi,
first think to come to mind....
you can use inputbox to prompt for parameters.
in this case it might be column letter.
but since you didn't post any code, i have no idea where
to put it or how to use it.

-----Original Message-----
I would like to thank everyone in advance for looking

into this for me.

I currently have a macro that inserts a blank row after

every cell in column
A that changes. See below:

Tom
Tom
Tom
Dick
Dick
Harry
Harry
Harry

The macro would insert a row after the 3rd Tom, the 2nd

Dick, and the third
Harry. I have come across the need to be able to pick

which column I want the
macro to examine. Sometimes column A, sometimes AB, etc.

Any suggestions?

Thanks again

Jeff







.


jeffbert

Insert rows in depending on criteria in variable columns
 
Sorry. Had it on my clipboard and everything. Here it is.

Sub InsertRows()
Dim cRows As Long
Dim i As Integer

For i = Cells(Rows.Count, "A").End(xlUp).Row To 2 Step -1
If Cells(i, "A") < Cells(i + 1, "A") Then
Cells(i + 1, "A").EntireRow.Insert
End If
Next i
End Sub


" wrote:

hi,
first think to come to mind....
you can use inputbox to prompt for parameters.
in this case it might be column letter.
but since you didn't post any code, i have no idea where
to put it or how to use it.

-----Original Message-----
I would like to thank everyone in advance for looking

into this for me.

I currently have a macro that inserts a blank row after

every cell in column
A that changes. See below:

Tom
Tom
Tom
Dick
Dick
Harry
Harry
Harry

The macro would insert a row after the 3rd Tom, the 2nd

Dick, and the third
Harry. I have come across the need to be able to pick

which column I want the
macro to examine. Sometimes column A, sometimes AB, etc.

Any suggestions?

Thanks again

Jeff







.




All times are GMT +1. The time now is 01:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com