LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default Help with a macro. Let's eliminate a loop...

I know I'm being dense, but I can't figure out the "right way" to do the
following...

I have 2 workbooks, call them "WBA" and WBB".

I'd like to write a macro (I have several 100 pairs of workbooks to do)
that sets cell {row x, Col A} of WBB to 1 if the number in cell {x,I}
exists anywhere in column A of WBA, otherwise cell {x,A} in WBB should
be 0

My thought (in pseudo code) is to do something like

n = number of rows in WBB
m = number of rows in WBA
for i = 1 to N
WBB.cell(i,A) = 0
for j = 2 to m '2 because WBA has a header row
if WBA.cell.value(j,A) == WBB.cell.value(i,I) then
WBB.cell.value(i,A) = 1
exit for
endif
next j
next i

while I'm sure it would work, it's not terribly efficient (in fact it's
pretty darn inefficient), especially given that each of WBA and WBB may
contain somewhere between 15 and 20 thousand rows.

Is there a better way?

Thanks!
Bruce

--
+-------------------+---------------------------------------------------+
Bruce Bowler | A good deed never goes unpunished. - Gore Vidal
1.207.633.9600 |
|
+-------------------+---------------------------------------------------+

 
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
Eliminate macro warning when you open a workbook Karlene Excel Discussion (Misc queries) 1 January 13th 10 05:45 PM
Create a macro to eliminate certain words from several columns Jorge Excel Worksheet Functions 4 January 16th 08 08:15 PM
Macro to eliminate extra space kleivakat Excel Discussion (Misc queries) 3 January 31st 06 12:21 PM
macro to eliminate repeating account numbers Sarah New Users to Excel 2 March 16th 05 11:11 PM
macro to eliminate spaces between words CSAM Excel Discussion (Misc queries) 3 December 17th 04 11:39 AM


All times are GMT +1. The time now is 08:20 PM.

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"