我有一個宏,我試圖寫。我在工作表事件後面有這個宏,如果在單元格D2中沒有應用宏,宏應檢查範圍A2,B2,C2是否不爲空。這應該適用於以下行A3,B3,C3,然後將宏應用於D3等。宏是由雙擊施加在所述單元VBA檢查單元格是否爲空 - 收件人Lastrow
問題:代碼未運行我希望它如上述的方式。
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
With Target
If .Column = 4 Then
Select Case .Row
Case 1, 2, 3, 4, 5, 6
Dim CheckCell As Range
For Each CheckCell In Sheets("Dates").Range("A1,B2,C2").Cells
If Len(Trim(CheckCell.Value)) = 0 Then
CheckCell.Select
MsgBox "Cell " & CheckCell.Address(0, 0) & " is empty. Click OK and populate it.", , "Missing Information"
Exit Sub
End If
Next CheckCell
.Value2 = "Prepared By" & " " & Environ("Username")
End Select
End If
End With
End Sub
您沒有設置'cancel = true'來避免'in-cell editing'。 – Jeeped
@Jeeped我需要爲此編輯代碼以及謝謝 – James
您的代碼與您的敘述沒有任何關係。 – Jeeped