我有VBA代码,自动输入日期+3天在特定的单元格时,在另一个单元格中输入一个名称。见下面的代码。我需要的是代码添加到这将删除日期时,名称被删除。
'When name entered in H34 date + 3 days is entered in H37
Private Sub Worksheet_Change(ByVal Target As Range)
'Auto fills Shipment Required By date in H37 When Name
'entered in H34 under Submitted BY
If Target.Cells.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("H34:H34")) Is Nothing Then
With Target(4, 1) ' Adjust numbers to match cell for date to go into -currently H37
.Value = Date + 3 'this will use date when name is entered into Order Submitted By cell and add 3 days
'Add .EntireColumn.AutoFit to fit data to cells. Does not work on merged cells
End With
End If
End Sub
从H34中删除名称时,需要添加代码以清除H37中的日期
已经尝试过这个,但它不工作。不同的代码建设从我原来的
If Sheets("OrderForm").Range("H34") = "" Then
Sheets("OrderForm").Range("H37").ClearContents
End if
1条答案
按热度按时间4zcjmb1e1#
此示例显示快速检查单元格是否有名称: