在EXCEL表格中自动生成不变的日期,请帮忙改下VBA代码
答案:4 悬赏:70 手机版
解决时间 2021-03-17 07:01
- 提问者网友:寂寞撕碎了回忆
- 2021-03-17 02:05
And Target;"Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Value <> ".Offset(0, 1) = "" Then
Target.Column = 1 And Target.Offset(0, 1) = Date
Else
Exit Sub
End If
End Sub
如果我要在B列中有数据时,对应的A列里自动生成当天日期且不变,跟以上代码刚刚相反,请朋友在以上的VBA代码帮忙改下
上太皇的提示:运行时错误'1004':运行时错误':应用程序定义错误或对象定义错误;wencuan的,我删除B的数据如果重新打人数据:类型不匹配;13',日期又变会今天了,我要的是该日期以后都不变了; qgrmdtj的全选清楚内容时提示
最佳答案
- 五星知识达人网友:忘川信使
- 2021-03-17 03:37
rivate Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 And Target.Value <> ",代码有点复杂,
-------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Target.Column = 1 And Target.Value <> ", -1).Value = "" Then
Target;>, 1).Offset(0, 1).Value = "" Then Exit Sub
If Target.Value = "".Offset(0, -1);" "" Then Exit Sub
If Target.Offset(0, 1).Value = "" Then Exit Sub
If Target.Column = 2 And Target.Value <> " Then Exit Sub
If Target.Column = 1 And Target.Value = "" _
And Target.Offset(0; _
And Target.Offset(0; "" Then Exit Sub
If Target.Column = 1 And Target.Value = "" _
And Target; "" _
And Target.Offset(0; _
And Target.Column = 1 And Target;>> Then Exit Sub
If Target.Value <.Column = 2 And Target, 1).Value <, -1).Value = "" Then
Target.Offset(0;"",各种情况都考虑到了.Value = Date
End If
End Sub
用这个试试; _
And Target.Offset(0.Value <".Value = ".Column = 1 And Target
If Target.Column = 1 And Target.Value <> ",代码有点复杂,
-------------------------------
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Target.Column = 1 And Target.Value <> ", -1).Value = "" Then
Target;>, 1).Offset(0, 1).Value = "" Then Exit Sub
If Target.Value = "".Offset(0, -1);" "" Then Exit Sub
If Target.Offset(0, 1).Value = "" Then Exit Sub
If Target.Column = 2 And Target.Value <> " Then Exit Sub
If Target.Column = 1 And Target.Value = "" _
And Target.Offset(0; _
And Target.Offset(0; "" Then Exit Sub
If Target.Column = 1 And Target.Value = "" _
And Target; "" _
And Target.Offset(0; _
And Target.Column = 1 And Target;>> Then Exit Sub
If Target.Value <.Column = 2 And Target, 1).Value <, -1).Value = "" Then
Target.Offset(0;"",各种情况都考虑到了.Value = Date
End If
End Sub
用这个试试; _
And Target.Offset(0.Value <".Value = ".Column = 1 And Target
全部回答
- 1楼网友:渡鹤影
- 2021-03-17 07:03
private sub worksheet_change(byval target as range)
if target.value <> "" and target.column = 1 and target.offset(0, 1) = "" then
target.offset(0, 1) = date
else
exit sub
end if
end sub
- 2楼网友:煞尾
- 2021-03-17 06:14
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 2 And Target.Value <> "" Then
Target.Offset(0, -1).Value = Date
End If
End Sub
请先在B列单元格输入数据
- 3楼网友:山有枢
- 2021-03-17 04:50
" And Target;"Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Value <> ".Offset(0, -1) = ".Column = 2 And Target; Then
Target.Offset(0
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯