循环遍历范围内的单元格,运行
SUBSTITUTE
,然后对列执行文本转换。
Private Sub CommandButton1_Click()
Dim myRng As Range
Dim LastRow As Long
LastRow = Sheets("Sheet1").UsedRange.Rows.Count
With Sheets("Sheet1")
Set myRng = Sheets("Sheet1").Range("A2:A" & LastRow)
End With
Dim cel As Range
For Each cel In myRng
cel.Value = WorksheetFunction.Substitute(cel.Value, "-", ", ")
Next cel
myRng.TextToColumns _
Destination:=Range("D2:E2:F2:G2:H2"), _
DataType:=xlDelimited, _
Tab:=False, _
Semicolon:=False, _
Comma:=False, _
Space:=True, _
Other:=True, _
OtherChar:=")"
End Sub