返回列表 上一主題 發帖

[發問] 如何在輸入完一段字後,在最前面加入統一匯款字樣

回復 3# s7659109
  1. Sub Add_Character()
  2. Dim A As Range
  3. For Each A In Range("B:B").SpecialCells(xlCellTypeConstants) '針對B欄位資料做檢查
  4.    If Left(A, 5) <> "統一匯款-" And A.Offset(, -1) <> "" Then
  5.    A = "統一匯款-" & A: A.Characters(1, 5).Font.ColorIndex = 3
  6.    ElseIf Left(A, 5) = "統一匯款-" And A.Offset(, -1) = "" Then
  7.    A.Characters(1, Len(A)).Font.ColorIndex = 0: A = Replace(A, "統一匯款-", "")
  8.    End If
  9. Next
  10. End Sub

  11. Private Sub Worksheet_Change(ByVal Target As Range)
  12. Application.EnableEvents = False
  13. Add_Character
  14. Application.EnableEvents = True
  15. End Sub
複製代碼
學海無涯_不恥下問

TOP

        靜思自在 : 一個缺口的杯子,如果換一個角度看它,它仍然是圓的。
返回列表 上一主題