Consulting

Results 1 to 3 of 3

Thread: Solved: Delete dash with space

  1. #1
    VBAX Mentor
    Joined
    Feb 2012
    Posts
    406
    Location

    Solved: Delete dash with space

    i have a data that all the cell have - (dash with space that mean after dash have a 1 space)

    i have this code for delete this dash but it is not work .and this dash will be in right with 1 space .

    Please help me

    [VBA]
    Sub Trim()
    For Each c In Worksheets("Sheet1").Range("A1:A3").Cells
    If Right(c.Value, 1) = "- " Then
    c.Value = Mid(c.Value, 1, Len(c) - 1)
    End If
    Next
    End Sub

    [/VBA]

    example : 2322424-

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [VBA]Sub Trim()
    For Each c In Worksheets("Sheet1").Range("A1:A3")
    If Right(c.Value, 2) = "- " Then
    c.Value = Left(c.Value, Len(c.Value) - 2)
    End If
    Next
    End Sub [/VBA]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Mentor
    Joined
    Feb 2012
    Posts
    406
    Location
    Thank you for your help

Posting Permissions

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