다음을 달성하고자합니다.
C 열은 데이터가 범위를 벗어나면 셀 배경이 빨간색으로 변하는 데이터 입력을 기반으로 조건부 서식이 지정되었습니다.
데이터가 입력되고 범위를 벗어난 데이터로 인해 셀이 조건부로 빨간색으로 서식 지정 될 때마다 필수 입력 상자를 통해 시트 하단에 데이터를 입력하고 싶습니다.이 예에서는 셀 B101에 주석이 작성되었습니다. B101에 이미 텍스트가 포함되어 있으면 주석이 B102에서 작성되고 B102에 텍스트가 포함되어 있으면 주석이 B103에서 작성되도록 아래 코드를 어떻게 변경합니까?
Private Sub worksheet_change(byval target as range)
If target.rows.count > 1 Or target.Columns.Count > 1 Then
Exit Sub
End if
Dim com As String
Dim comm1 As String
Set isect = Application.Intersect(target,Range("C1:C100"))
If isect Is Nothing Then
Else
If target.DisplayFormat.Interior.Color = RGB(255,0,0) Then
com = "Enter comment at bottom of sheet"
Do While comm1 = ""
comm1 = Application.InputBox(prompt:=com, Type:=2)
On Error GoTo myloop
If comm1 = False Then
comm1 = ""
End If
myloop:
On Error GoTo -1
Loop
Range("B101").Value = comm1
Else
Range("B101").value = ""
End If
End If
End Sub
Do While 루프를 추가 할 수 있습니다.
Dim i As Long
i = 101
Do While Range("B" & i).Value <> ""
Debug.Print Range("B" & i).Address
i = i + 1
Loop
' Now that we're out of the loop, the next cell will be empty
Range("B" & i).Value = "Comment here"
편집 : 또는 그냥 할 수 있습니다 Range("B101").End(xlDown).Offset(1,0).Value = "Comment Here"
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다