Share via

Replace First space

Anonymous
2011-10-23T03:33:40+00:00

Is there anyway to replace only the first space after the first tab in that row with comma in microsoft word 2010

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2011-10-24T06:02:13+00:00

The following looks at the first 'word' in the paragraphs. Word treats a tab character as a 'word', so if the first 'word' is not a tab character (as in your first example), this version adds a tab character to the start of the second 'word'

Dim oPara As Paragraph

Dim oRng As Range

For Each oPara In ActiveDocument.Paragraphs

    If oPara.Range.Words.Count > 1 Then

        If oPara.Range.Words(1).Text <> Chr(9) Then

            Set oRng = oPara.Range.Words(2)

            oRng.InsertBefore Chr(9)

        End If

    End If

Next oPara

Was this answer helpful?

0 comments No comments

5 additional answers

Sort by: Most helpful
  1. Anonymous
    2011-10-23T12:05:06+00:00

    This doesn't help. We cannot see your document and we have no idea how it is currently formatted or what you want to do with it. You say you 'are trying to make a table'. What is your starting point? Is the document already a table?

    If as seems likely the document is not yet a table, then the following macro will add a tab to the start of any paragraph that doesn't already have one. If it is already a table then give us more detail.

    Dim oPara As Paragraph

    For Each oPara In ActiveDocument.Paragraphs

        If Asc(oPara.Range.Characters(1)) <> 9 Then

            oPara.Range.InsertBefore Chr(9) 'Chr(44) if you want a comma instead

        End If

    Next oPara

    http://www.gmayor.com/installing_macro.htm

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2011-10-23T11:15:25+00:00

    The whole document?t

    we are trying to make a table by breaking up the rows don't have a tab in the begining of paragraph, we want to put tab or comma at first space of those rows to be able to have a colimn

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2011-10-23T04:52:15+00:00

    That is an "advanced" find type search. It probably can be done, but we would need several example lines to be able to tell.

    Here are a couple of resources to help you DIY

    ·       Advanced Find and Replace in Microsoft Word, Jack M. Lyon, © 2002 by the Editorium. All rights reserved. http://www.editorium.com/ftp/advancedfind.zip

    ·       Find and Replace Using Wildcards http://www.gmayor.com/replace_using_wildcards.htm

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2011-10-23T04:46:01+00:00

    'That row'? Is this a table? Can you describe more fully what you are trying to do?

    Was this answer helpful?

    0 comments No comments