Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
find and replace numeric strings in larger text strings | Excel Worksheet Functions | |||
How to find number of pairs of strings from list of strings? | Excel Worksheet Functions | |||
Collection Class problems | Excel Programming | |||
RaiseEvent from a class contained in a 2nd class collection? | Excel Programming | |||
For/Each iteration for collection class | Excel Programming |