ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Insert Row (https://www.excelbanter.com/excel-discussion-misc-queries/129730-insert-row.html)

tom

Insert Row
 
Working in Excel 2007, I have a column (B) that when the number changes I
want a macro to insert a row... Approx 16K rows that need to be evaluated.

Example Desired Result
2333 2333
2333 2333
2333 2333
2335
2335

TFTH,
Tom


Dave O

Insert Row
 
By coincidence I have a utility macro I wrote to do just that. To use
it, go to the bottom of the list and after the last cell enter the
word "stop" (without quotes) in that cell. Then place the cell pointer
at the top of the list and run this code.

Sub InsertRow()
With Application
.Calculation = xlManual
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False

Dim A, B

Do Until ActiveCell.Value = "stop"
A = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
B = ActiveCell.Value

If A < B Then
Selection.EntireRow.Insert
ActiveCell.Offset(1, 0).Select
End If
Loop

With Application
.Calculation = xlAutomatic
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False

Calculate
End Sub


tom

Insert Row
 
Dave,
Works like a charm!!! Thanks... Tom

"Dave O" wrote:

By coincidence I have a utility macro I wrote to do just that. To use
it, go to the bottom of the list and after the last cell enter the
word "stop" (without quotes) in that cell. Then place the cell pointer
at the top of the list and run this code.

Sub InsertRow()
With Application
.Calculation = xlManual
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False

Dim A, B

Do Until ActiveCell.Value = "stop"
A = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
B = ActiveCell.Value

If A < B Then
Selection.EntireRow.Insert
ActiveCell.Offset(1, 0).Select
End If
Loop

With Application
.Calculation = xlAutomatic
.MaxChange = 0.001
End With
ActiveWorkbook.PrecisionAsDisplayed = False

Calculate
End Sub




All times are GMT +1. The time now is 02:14 PM.

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