사용자에게 지정된 셀 범위를 자동으로 지정하기위한 VBA 매크로가 있는데 제대로 작동합니다. 그러나 사용자가 지정된 범위에서 행을 삭제하려고하면 내가 무한 루프로 빌드 한 오류 메시지가 트리거됩니다.Excel VBA 매크로 행 삭제 무한 루프
코드는 다음과 같습니다
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rTimeCells As Range
Set rTimeCells = Range("D2:G15")
Application.EnableEvents = False
If Not Application.Intersect(rTimeCells, Range(Target.Address)) Is Nothing Then
Call Time_Format(Range(Target.Address))
End If
Application.EnableEvents = True
End Sub
Private Sub Time_Format(rCells As Range)
Dim RegEXFormat1 As Object
...
Dim RegEXFormatX As Object
Set RegEXFormat1 = CreateObject("VBScript.RegExp")
...
Set RegEXFormatX = CreateObject("VBScript.RegExp")
RegEXFormat1.Global = True
...
RegEXFormatX.Global = True
RegEXFormat1.IgnoreCase = True
...
RegEXFormatX.IgnoreCase = True
RegEXFormat1.Pattern = "..."
...
RegEXFormatX.Pattern = "..."
For Each cell In rCells
Dim sValue As String
Dim sMonth As String
Dim sDay As String
Dim sYear As String
Dim bCorrectFormat As Boolean
bCorrectFormat = True
sValue = CStr(cell.Text)
If (RegEXFormat1.test(sValue)) Then
...
ElseIF(RegEXFormatX.test(sValue) Then
...
Else
If (sValue = "" Or sValue = "<Input Date>") Then
Else
MsgBox ("Please Input the date in correct numeric format")
cell.value = "<Input Date>"
End If
Next
사용자는 그들이 루프에이 매크로를 전송하지 않고 데이터의 행을 삭제할 수있는 기능이 필요하다는 것을 주장한다. 이 발생을 허용하기 위해 내가 가지고있는 것을 어떻게 수정할 수 있습니까?
는 (I 명확하게 코드를 수정하고 내가 느끼는 그나마 여기 필요했다 및 페이지와 페이지 오래되는 것을 내 게시물을 중지하는 많은을 떠났다.)이 대신
+1 "사용자는이 매크로를 루프로 보내지 않고 데이터 행을 삭제할 수 있어야한다고 주장합니다. " – Brad