Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default optimize cycle's speed - For, Next or DO, UNTIL; IF-THEN, ENDIF or CASE, ENDCASE

Hi,
I have cycle which is checking duplicates names in column 12.

For j = 1 To 65000
dupl = Sheets("Sheet1").Cells(j, 12).Value
If dupl = strText Then
c = c + 1
numbere = numbere + 1
Else
End If
Next j


The cycle become slower when j is growing.
I want to optimize cycles for speed.

Should I change For, Next cycle to DO, UNTIL (or any other)?
Should I change IF-THEN, ELSEIF, ELSE, ENDIF to
CASE, ENDCASE (or any other)?

Is this effecting speed?

Thank you

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,071
Default optimize cycle's speed - For, Next or DO, UNTIL; IF-THEN, ENDIF or CASE, ENDCASE

You need to leverage the fact that you are working with VB*A*; focusing
on VB syntax will, if you are lucky, give you a tiny % in improvement.
Focusing on the XL object model has the potential to be significantly
more rewarding. Look up the XL VBA help files for the Find method.
Let XL do the work for you! Or use the COUNTIF formula, as in

MsgBox Application.WorksheetFunction.CountIf( _
Range("a1:a65536"), Range("a1").Value)

It takes a fraction of a second to get an answer when all 65,536 rows
contain data.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article , Oleks
says...
Hi,
I have cycle which is checking duplicates names in column 12.

For j = 1 To 65000
dupl = Sheets("Sheet1").Cells(j, 12).Value
If dupl = strText Then
c = c + 1
numbere = numbere + 1
Else
End If
Next j


The cycle become slower when j is growing.
I want to optimize cycles for speed.

Should I change For, Next cycle to DO, UNTIL (or any other)?
Should I change IF-THEN, ELSEIF, ELSE, ENDIF to
CASE, ENDCASE (or any other)?

Is this effecting speed?

Thank you.


---
Message posted from http://www.ExcelForum.com/


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP! optimize calculating values Cam Excel Discussion (Misc queries) 3 April 22nd 08 05:15 PM
How to end my macro in If-else-Endif Tan New Users to Excel 1 April 6th 07 10:48 AM
Optimize SumProduct Christopher Kennedy Excel Discussion (Misc queries) 9 December 10th 04 04:47 PM
Optimize SumProduct chris Excel Worksheet Functions 3 December 9th 04 08:39 AM
How can I optimize this code? wullux Excel Programming 2 December 17th 03 07:13 PM


All times are GMT +1. The time now is 07:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"