我想从单元格中删除主要的aphostrophe,并希望它们只能通过宏在excel中以文本格式显示

时间:2016-11-18 12:46:27

标签: vba macros

Private Sub CommandButton1_Click()

Dim c As Long
With Range("B1:B999").CurrentRegion
    .Replace What:="'", Replacement:=vbNullString, LookAt:=xlPart
End With
Range("B1:B999").NumberFormat = "@"


End Sub

1 个答案:

答案 0 :(得分:0)

您的问题尚不清楚,但也许您正在寻找类似的内容:

Dim ws as Worksheet
Set ws = ActiveWorkbook.Worksheet("NAME HERE")
Dim rng as range
Dim strInput as string, strOutput as string

For each rng in ws.columns(2).rows("1:999")
    strInput = ws.Columns(2).Rows(rng.Row)
    strOutput= Replace(strInput , "'", "")
    ws.Columns(2).Rows(rng.Row) = strOutput
Next rng