View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Frank Kabel Frank Kabel is offline
external usenet poster
 
Posts: 3,885
Default .select efficiency

Hi
If I read you code correctly just remove the line
Cells(r, c).Select
your code should work fine without this line as you are referencing the
cells directly

Frank

Lawlera wrote:
Selecting cells in a loop routine appears to be terribly inefficient.
The code I have is:
Sub errorchk()
Dim s1, s2 As String
Dim r As Variant
Application.ScreenUpdating = False
s1 = "sheet1"
s2 = "sheet2"
For r = 1 To 100
For c = 1 To 26
Cells(r, c).Select
If Sheets(s1).Cells(r, c).Value < Sheets(s2).Cells(r, c).Value
Then MsgBox "error at " & ActiveCell.Address Next c
Next r
MsgBox "Check complete"
Application.ScreenUpdating = True
Range("a1").Select
End Sub

.. but would be grateful if anyone has code that can do the same
quicker as the check range needs to expand.

Thank you in anticipation.