I have a macro that is comparing 2 cells and inserting a blank row between them if they are different. It was taking about 12 minutes to complete this process with this code:
Worksheets("Dollars").Activate
Range("B10").Select
' Do Until ActiveCell.Formula = ""
' DoEvents
' If ActiveCell <> ActiveCell.Offset(1, 0) Then
' ActiveCell.Offset(1, 0).Activate
' Selection.EntireRow.Insert
' End If
' ActiveCell.Offset(1, 0).Activate
' Loop
I rewrote the code to this way to see if it was any better and it still took over 12 minutes to run.
Dim r As Long
Dim vStr1 As String
Dim vStr2 As String
r = 10
vStr1 = ""
vStr2 = ""
Do Until Len(Trim(Cells(r, 2))) = 0
DoEvents
vStr1 = ""
vStr2 = ""
vStr1 = Trim(Cells(r, 2))
vStr2 = Trim(Cells((r + 1), 2))
If vStr1 = vStr2 Then
' do nothing
Else
Cells((r + 1), 1).EntireRow.Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
r = r + 1
End If
r = r + 1
Loop
is there a better way to do this so it doesn't take so long? We are using Windows 10 and Office 2016. Thanks for the help. I appreciate it....