回覆列表
  • 1 # 使用者4187660024957

    Sub ReplaceEpeciallyString() Dim ws As Worksheet Dim i, j As Integer Dim findString As String findString = vbCr Dim replaceString As String replaceString = "&" Dim cellString As String Dim findResult As Integer Dim newString As String For Each ws In Worksheets For i = 1 To ws.UsedRange.Rows.Count For j = 1 To ws.UsedRange.Columns.Count cellString = ws.Cells(i, j) findResult = InStr(1, cellString, findString, vbTextCompare) If findResult > 0 Then newString = Replace(cellString, findString, replaceString) ws.Cells(i, j) = newString End If Next j Next i NextEnd Sub

    findString = vbCr 這個是VBA裡面表示換行符的

    replaceString = "&" 替換成你想要的符號

    注意,這個是替換到掉整個工作薄。

    VBA 替換工作簿中所有工作表中的特定字元

  • 中秋節和大豐收的關聯?
  • 棉布用什麼染料?