Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50194

Speeding macro transfering data in to vb and back

$
0
0
Hey Fellows,

Any ideas on how to implement the following speed tip

"Another thing you should list before “If all else fails” is proper transfer of data from Excel to VBA and back. Don’t read and write one cell at a time. That one access operation per range is probably the slowest part of the VBA code. Read the entire range you need in one step into a VB array, process the data, and dump a new array into the worksheet."



on the following code?

Code:

Sub deleteCommonValue()
Dim aRow, bRow As Long
Application.ScreenUpdating = False
aRow = 2
bRow = 3

Do
If Range("B" & bRow).Value <= (Range("B" & aRow).Value + 0.05) _
    And Range("B" & bRow).Value >= (Range("B" & aRow).Value - 0.05) Then
   
    If Range("C" & bRow).Value <= (Range("C" & aRow).Value + 0.05) _
        And Range("C" & bRow).Value >= (Range("C" & aRow).Value - 0.05) Then
       
        If Range("D" & bRow).Value = (Range("D" & aRow).Value) _
            Or Range("D" & bRow).Value > (Range("D" & aRow).Value) Then
            Range(bRow & ":" & bRow).Delete
        Else
            Range(aRow & ":" & aRow).Delete
            bRow = aRow + 1
            Range("A" & aRow).Select
        End If
       
    Else
        bRow = bRow + 1
        Range("A" & bRow).Select
       
    End If
   
Else
    bRow = bRow + 1
    Range("A" & bRow).Select
End If
If IsEmpty(Range("D" & bRow).Value) = True Then
    aRow = aRow + 1
    bRow = aRow + 1
End If
Loop Until IsEmpty(Range("D" & aRow).Value) = True

End Sub


Viewing all articles
Browse latest Browse all 50194

Trending Articles