NestMeUp and SpaceMeOut - Excel 2000

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15633
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

NestMeUp and SpaceMeOut - Excel 2000

Post by ChrisGreaves »

The attached text file contains a string copied from an Excel cell; only the names of variables have been changed to protect the innocent.

The macros NestMeUp and SpaceMeOut are meant to be pasted into a Word module.

I paste an offensive cell formula into a blank Word document and run SpaceMeOut to insert spaces to make the formula readable.

I paste an offensive cell formula into a blank Word document and run NestMeUp to assign colors to different levels of nesting to make the formula readable.
You do not have the required permissions to view the files attached to this post.
There's nothing heavier than an empty water bottle

User avatar
HansV
Administrator
Posts: 78510
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: NestMeUp and SpaceMeOut - Excel 2000

Post by HansV »

Hi Chris,

In Office 2000 and later, VBA has a built-in function Replace that works the same as strReplaceAll, but faster.
Best wishes,
Hans

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15633
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: NestMeUp and SpaceMeOut - Excel 2000

Post by ChrisGreaves »

HansV wrote:... built-in function Replace that works the same as strReplaceAll, but faster.
That's all very well for you to say, Hans, but right now I'm being paid hourly-rate to work from home. :evilgrin:

(Thanks anyway!)
I guess I wrote strReplaceAll back in Word97 days and just got used to it.
I'll drag myself, kicking and screaming, into the New Millennium next time around, I promise.
There's nothing heavier than an empty water bottle

User avatar
HansV
Administrator
Posts: 78510
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: NestMeUp and SpaceMeOut - Excel 2000

Post by HansV »

The macros are interesting, but I found one problem with SpaceMeOut: underscores are allowed in defined names in Excel, e.g. January_Sales. The SpaceMeOut macro will change this to January _ Sales, which is not a valid name any more since it contains spaces.
Best wishes,
Hans

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 15633
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: NestMeUp and SpaceMeOut - Excel 2000

Post by ChrisGreaves »

HansV wrote:underscores are allowed
Thanks for catching this, Hans.
As you might guess these two were "quickies" dashed off this afternoon to solve a specific and recurring problem.
The fix will be:
Public Const strcAlpha As String = strcLowerAlpha & strcUpperAlpha & "_"
There's nothing heavier than an empty water bottle