1 x blank space before the beginning of the Task name text RRS feed

  • General discussion

  • Hello,

    I know this is minor, but I have a project where there are there are many Task Names that have 1 x blank space before the beginning of the Task name text. My project is about 1200 rows, so I don't want to go into each one and hit F2, home, then delete to get rid of the extra space. Anybody know how this happened in the first place?

    Thank you for your support.

    Tuesday, January 10, 2017 8:00 PM

All replies

  • PFTUSMA89ND99 --

    There is no easy way to accomplish what you seek, short of writing a macro in the VBA programming language to detect and suppress leading spaces.  Several others in this group very willingly share macros, so I will invite them to help you with some VBA code to accomplish this.

    As to how this happened, I have seen this when people copy and paste tasks from Excel.  But beyond that, who knows what causes the leading spaces in task names, anyway?  Hope this helps.

    Dale A. Howard [MVP]

    Tuesday, January 10, 2017 9:46 PM
  • This is what I do.

    Copy the entire list of task names. Paste it into EXCEL. In the column next to it, say in B1, make a formula using the Trim() function, eg Trim(A1), and fill the formula down to the bottom of the list. Then copy and paste the list back into MSP. Trim takes off leading and trailing spaces and double spaces.

    Alternatively, insert a spare Text column and put a formula in there using the Trim() function in MSP.

    I also like to use Title Case for task names, with a cap on the first character of each word. So I copy the list, paste into a spreadsheet, and use a nested formula like Proper(Trim(A1)).

    Any help?

    Tuesday, January 10, 2017 10:46 PM
  • PFTUSMA89ND99,

    Trevor gave you a couple of approaches and if that meets your needs, great. This macro will also do the trick.

    Sub clearspaces()
    Dim t As Task
    For Each t In ActiveProject.Tasks
        t.Name = Trim(t.Name)
    Next t
    End Sub


    Tuesday, January 10, 2017 11:05 PM