Solving a recent custom field formula problem required reaching into the toolbox and pulling out the trim() string function. Trim is one of the simplest string functions. It does one thing and does it well. It just strips any leading or trailing spaces from a text string. So if you have a string like this:
myString = " There is space in front and in back "
you can use:
trim(mystring)
to return "There is space in front and in back"
The problem was that converting a Microsoft Project Unique ID to a string adds a leading space to the string (why? I don't know, but it does) so you can use trim to obtain just the characters you want.
Trim is not just a VBA function, you can use it in Excel formulas, MS Project custom field formulas and just about any programming language I've seen. I've used it extensively with spreadsheets that contain data pasted in from other sources.
Comments (1)
You wrote "The problem was that converting a Microsoft Project Unique ID to a string adds a leading space to the string (why? I don't know, but it does) ..."
While this is true, you should note that when working in VBA there is no leading space. For example:
In the P2003 Pro immediate window
?""
shows
A macro which loops through all tasks displaying:
""
also doesn't show any leading spaces.
Posted by JohnB | February 3, 2007 12:37 PM
Posted on February 3, 2007 12:37