C
CB
I have written a bit of code to delete a comma if it happens to be the first
character in a string, however my code seems to be deleting all commas, I am
a VB beginner can anyone help me out?
What I thought my code did:
If have ",,Hello, my, name,,, is" in a cell before I run the code, after I
run the code I would like the cell to look like "Hello, my, name,,, is"
What my code seems to do:
Output: "Hello my name is"
This is my code (I have pieced it together from looking at the forum so I
may not fully understand what is going on):
Sub ahhhhhhhh()
For Each cell In Range("H59:H60")
If InStr(1, cell.Value, ",", vbTextCompare) = 1 Then
cell.Value = Replace(cell.Value, ",", "", 1, -1, vbTextCompare)
End If
Next
End Sub
character in a string, however my code seems to be deleting all commas, I am
a VB beginner can anyone help me out?
What I thought my code did:
If have ",,Hello, my, name,,, is" in a cell before I run the code, after I
run the code I would like the cell to look like "Hello, my, name,,, is"
What my code seems to do:
Output: "Hello my name is"
This is my code (I have pieced it together from looking at the forum so I
may not fully understand what is going on):
Sub ahhhhhhhh()
For Each cell In Range("H59:H60")
If InStr(1, cell.Value, ",", vbTextCompare) = 1 Then
cell.Value = Replace(cell.Value, ",", "", 1, -1, vbTextCompare)
End If
Next
End Sub