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: 3
Default Using a collection class to implement mutliple find/replace strings in cells

I need to iterate over a row of cells, and if the value matches
string1, replace it with string2. There's no inherent ordering.

I found that with a class called ReplaceColumnTitle which has two
properties oldstring and replacementstring, and a collection
CollReplaceColumnTitle, I can easily iterate over each
ReplaceColumnTitle in the CollReplaceColumnTitle, test the cell value
against each oldstring and replace it if it matchs.

I don't see any 'good' way to encapuslate all the
oldstring/replacementstring pairs (there are about 30, and growing)
for populating the collection CollReplaceColumnTitle. I know XML is
probably perfect for this, but the learning curve for adding XML
programming to Excel macros using VBA is too costly for my immediate
needs, I think.

one way I've considered is to create a collection class, and to add
the name/value pairs to the collection during Class_Initialize. That
lets me isolate the information into the class module. I've tried to
do this, but:

How do I tell VBA that the new class is a collection?

How do I refer to 'myself' within the Class_Initialize subroutine?

Example:
Private Sub Class_Initialize()

Dim acr As ReplaceColumnTitle
Set acr = New ReplaceColumnTitle
acr.OS = "Transport Service CPU"
acr.RS = TransportCPUPM
Me.Add acr
end sub
I've tried Me.Add, This.add, .Add - nope on any of them.

Thanks for any suggestions, especially big-picture ones that offer a
good way to encapsulate the name/value pairs!
 
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
find and replace numeric strings in larger text strings Mr Molio Excel Worksheet Functions 8 November 9th 11 05:17 PM
How to find number of pairs of strings from list of strings? greg_overholt Excel Worksheet Functions 5 January 27th 06 10:42 PM
Collection Class problems Flemming Dahl Excel Programming 4 February 11th 04 04:41 PM
RaiseEvent from a class contained in a 2nd class collection? Andrew[_16_] Excel Programming 2 January 6th 04 04:22 PM
For/Each iteration for collection class Stelio Excel Programming 1 October 31st 03 12:46 PM


All times are GMT +1. The time now is 02:21 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"