返回列表 上一主題 發帖

[發問] 如何判斷儲存格中有冒號?

  1. Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
  2. Dim i&, j&
  3. If Not Target.Column = 2 Or Len(Target.Value) = 0 Then Exit Sub
  4. i = Target.Row
  5. If i < 2 Or Right(Target.Value, 1) = ":" Then Exit Sub
  6. Cells(i, 1) = Application.Max(Range("a1:a" & i)) + 1
  7. j = i
  8. Do
  9.     j = j - 1
  10. Loop Until Right(Cells(j, 2), 1) = ":"
  11. Cells(i, 3).Value = Left(Cells(j, 2).Value, Len(Cells(j, 2).Value) - 1)
  12. End Sub
複製代碼

zz.zip (13.21 KB)

TOP

        靜思自在 : 信心、毅力、勇氣三者具備,則天下沒有做不成的事。
返回列表 上一主題