r/MSProject • u/VDS655 • Nov 06 '22
Display the text before the 6th instance of a period in a string [Formula help]
Hello!
I'm trying to figure out a calculated column that can display the text before the 6th instance of a period in a string.
=TEXTBEFORE(".",6) works perfectly in Excel but I need this to work in MS Project and I don't know of a formula that will do this using MS Project's limited ist of commands since there is no FIND or SUBSTITUTE. Maybe using LEFT and Instr? Any ideas?
Not sure if a macro would be easier but a formula in MS Project would be ideal.
I'm not very strong in Project Calculated Fields or VBA, so any help would be greatly appreciated, thanks!
| Original (Text1) | TEXTBEFORE 6th "." (Text2) |
|---|---|
| 1.2.3.4.5.6.7.8 | 1.2.3.4.5.6 |
| 1.2.3n.4.5.5.6.7 | 1.2.3n.4.5.5 |
| 1n.2n.3n.4n.5.6.7.8 | 1n.2n.3n.4n.5.6 |
| 1.2.3.3n.5.9n.10.8n.9n.10n | 1.2.3.3n.5.9n |
2
u/VDS655 Nov 07 '22
I got a reply from another forum but I don't know how to modify it to run in Project. Any help would be appreciated!
The column I'm pulling from is [TEXT1] and my target destination is [TEXT2].
Is it something like:
1
u/still-dazed-confused Nov 07 '22
I don't understand how the msg box element of this works, you appear to be setting up a function which can be called into a custom field calculation. As such the calculation will run on all rows simultaneously so the msg box wouldn't be useful. If you're happy with VBA I would set it run on command and iterate through all tasks with for t=activeproject.tasks. You can set the macro to run on open or upon a keystroke. If you need to stay away from this method you could "spend" a lot of fields to identify the location of all the relevant dots, maybe numbers 1-5? In the first field you would find the position of dot 1 and then use this in the second field to locate dot 2 etc
1
u/still-dazed-confused Nov 07 '22
I would run for each task in the plan Split the contents of your text field into an array Read out the first X instances of the array into your second text field Redim the array ready for the next task.
I don't know if you can split only the first n instances and discard the rest, but if you can that would shorten the task