View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ken Wright Ken Wright is offline
external usenet poster
 
Posts: 634
Default Is this slow code?

Am I doing something really ineffcicent?

Yes, you are using VBA :-)

From your description I would say that this can probably be done instantly using
existing functions such as COUNTIF or MATCH or SUMPRODUCT / VLOOKUP etc. If you
can give us a bit more info regarding your data with maybe some examples and
ranges, then we can probably help you do this quite easily. If you are hard
over that you need to use VBA then post the code you are using. If you are
looping through all the cells then you may want to use the Find method. If you
are selecting cells then don't as this will slow things down enormously. Give
us a bit more to play with here and we'll get you sorted ;-)

--
Regards
Ken....................... Microsoft MVP - Excel
Sys Spec - Win XP Pro / XL 00/02/03

----------------------------------------------------------------------------
It's easier to beg forgiveness than ask permission :-)
----------------------------------------------------------------------------



"Tom" wrote in message
...
Hi all,

Is my implementation the best way to do this?? My code works but it is very
very
slow - but my user base which will use the code are al on P2's as well!

I am trying to achieve the following:

I have a list of 30 items in a col in a spread sheet.
I have 1 other cell which are constants
I have a [5][1000] table on another sheet in the spready, of which I am
retreiving only values from 2 columns.

For each item in the 30 column list, I want to check all 1000 rows, to
determine if any of the rows match the item, and the 1 constant. If a match
is found then I'm done and I break out.


Am I doing something really ineffcicent?

any help

Thanks

Tom



'Set up the loop. This is a decrementing loop becuase we want to delete
items out of it _
with out effecting the index
'Note the list stops at 2 to ensure the Heading is not removed.
For listCount = listLoop To 2 Step -1
' set the delete condtion to true
DeleteLogic = True
' get the item at the bottom of the list
listValue = Sheet13.Range(listRange & listCount)

' Set up the second loop which will loop through the entire config
table this loop _
increments
For rConfigCount = 2 To rConfigLoop
' Perform the test: If the workstream and list values exsist in
a config row _
then do not delete
If Trim(listValue) < "" _
And _
rConfig.Cells(rConfigCount, configCheck1).Value = listValue _
And _
rConfig.Cells(rConfigCount, configCheck2).Value = userSelection
_
Then
' if a match is found then I don't want to delete
DeleteLogic = False
' if a match is found there is not point searching the rest
of the table.
Exit For
End If

Next rConfigCount
'Perform delete if necessary
If DeleteLogic = True Then _
Sheet13.Range(listRange & listCount).Delete xlShiftUp

Next listCount





---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.608 / Virus Database: 388 - Release Date: 03/03/2004