Insert Row

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 

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

Similar Threads

count 1
sql help req 1
code needed, please 3
No. of columns in a Pivot Table 1
selecting proper RAM for a HP xw4600 Workstation 1
Calculation based on a condition 3
VBA - Print Selection 2
Inserting a row (update) 2

Back
Top