Results 1 to 2 of 2
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Thanked 0 Times in 0 Posts
    Acolum A, rows 1-500I have cells that are empty and ones that have text. What I would like is a macro that would remove all of the text to the right of a space before a dash (" -"). For example, assume the text "John - BigGreenMachine" is in A1. I would like a macro that would remove the " - BigGreenMachine" from the cell. Keep in mind there is different text in each cell, but there is always a dash with a space before it in each of the cells with text. Any ideas? Thanks in advance.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Thanked 28 Times in 28 Posts
    Dim r As Long
    Dim p As Long
    For r = 1 To 500
    p = InStr(Range("A" & r), " -")
    If p > 0 Then
      Range("A" & r) = Left(Range("A" & r), p - 1)
    End If
    Next r

Posting Permissions

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