View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
L. Howard L. Howard is offline
external usenet poster
 
Posts: 852
Default A faster code maybe?

These both do the same work (different column on sheet4) and seem to have no speed advantage either way.

Is code 1 properly written or can it be made faster.

Howard

Sub Column_OneRng1()
Dim LRow As Long, i As Long
Dim varData As Variant

Application.ScreenUpdating = False
With Sheets("Sheet3")
LRow = .Cells(Rows.Count, 4).End(xlUp).Row
varData = .Range("A2:F" & LRow)
For i = 1 To UBound(varData)
If varData(i, 4) < 150 Then
Sheets("Sheet4").Cells(Rows.Count, 1) _
.End(xlUp)(2) = varData(i, 1)

Sheets("Sheet4").Cells(Rows.Count, 3) _
.End(xlUp)(2) = " Type-" & varData(i, 5)

Sheets("Sheet4").Cells(Rows.Count, 5) _
.End(xlUp)(2) = " Age-" & varData(i, 6)

End If
Next
End With

Application.ScreenUpdating = True

End Sub



Sub Column_OneRng2()
Dim OneRng As Range
Dim c As Range

Set OneRng = Sheets("Sheet3").Range("D2:D" & Cells(Rows.Count, "D").End(xlUp).Row)

For Each c In OneRng
If c < 150 Then
Sheets("Sheet4").Range("B" & Rows.Count).End(xlUp)(2) = c.Offset(, -3)
Sheets("Sheet4").Range("D" & Rows.Count).End(xlUp)(2) = " Type-" & c.Offset(, 1)
Sheets("Sheet4").Range("F" & Rows.Count).End(xlUp)(2) = " Age-" & c.Offset(, 2)
End If
Next
End Sub