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: 553
Default Running total of Found Substrings in MainString in Big Loop

I am searching text strings. I have a loop which assesses sub strings within
a string. The search is looking for about 300 defined strings. I want the
ability to count the occurences of each substring during the entire loop.
However as there are 300 of them, I am not sure how to approach this.
Normally I would do the following below (very crude example). However as you
can see I would need 300 Counter variables for the 300 defined terms.
Furthermore, if mulitple occurences are found in each string my simple +1
logic will not work. I know I can also use regex for the string search
(could make pattern = (item1|itme2|item3 etc) and track multiple occurences,
but need some guidance on how to calc the running totals on these 300
separate items without creating 300 separate counter variables.

Is there a way to do this using class modules?

Dim Item1 as String
Dim Item2 as String
Dim MainStringArray As Variant()

Item1 = "abcd"
'Just assume I have loaded my aray with strings
'?MainStringArray(0) =" .........1234abcde@@@@@@@ABCDE"

Item1Counter = 0

For X = 1 to 1000
'Test to see if substring exists in MainString
IF substringexists(Item1, MainStringArray(X-1))
Item1Counter=Item1Counter +1
End if
Next

Sub substringexists() as Boolean
'Code to search mainstring
'If match substringexists = TRUE
'End If
End Sub

Thanks

EM

 
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
Duplicate Running Total Grand Total In Pivot Table Mathew P Bennett[_2_] Excel Discussion (Misc queries) 1 August 17th 08 03:13 AM
running total and average of that total after 3 events belvy123 Excel Discussion (Misc queries) 0 March 28th 07 02:57 AM
running total and average of that total after 3 events Toppers Excel Discussion (Misc queries) 1 March 28th 07 02:19 AM
% of Running Total to Grand Total in Pivot Table David Excel Programming 0 August 17th 05 08:24 PM
running a sub when found solo_razor[_32_] Excel Programming 2 November 14th 03 01:41 PM


All times are GMT +1. The time now is 04:53 PM.

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

About Us

"It's about Microsoft Excel"