-
Delete the dash from first and end of cell
I have a VBA code that delete Dash - from end of cell now I want also delete the dash of first of my data
like :
-12121121
When run VBA code delete the first - .
also if have -12121121- when run code delete dash and will be 12121121
[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]
-
you can fusion your code with this one
[VBA]Sub Parscon()
Dim Counter As Integer
Dim MyString As String
Dim c As String
Dim data1 As String
MyString = "-Automa-teExc-el" 'define string, here should be the line to unify your code
For Counter = 1 To Len(MyString)
c = Mid(MyString, Counter, 1)
If c <> "-" Then
data1 = data1 & c 'loop to reintegrate one by one the characters exlcluiding -
End If
Next
MsgBox data1
End Sub
[/VBA]
-
or
[VBA]
sub M_snb()
Sheets("Sheet1").Range("A1:A3").replace "-",""
end sub
[/VBA]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules