Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Apr 2004
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Clear cells that begin with a space (Excel 2002)

    I am running a macro in Excel, but I cannot figure out the code to insert that will clear the contents of all cells in columns E through J that begin with a space. I do not want to clear the contents of the cells that begin with alpha numeric characters. Can anyone help?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Clear cells that begin with a space (Excel 2002)

    This could be done by a simple Edit | Replace action. Its macro equivalent is
    <code>
    Sub ClearCellsWithLeadingSpace()
    Range("E:J").Replace What:=" *", Replacement:="", LookAt:=xlWhole
    End Sub
    </code>
    The macro uses a Replace command with * as wildcard in the What argument: <code>" *" </code> finds all cells whose contents start with a space.

  3. #3
    New Lounger
    Join Date
    Apr 2004
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Clear cells that begin with a space (Excel 2002)

    Thanks, Hans! Worked like a charm! I can't believe it was that simple!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •