如何将Excel编码为VBA?从Target.Offset(0, -4).Value =
右侧开始
我不知道如何在VBA中说这个:(Text(TODAY(), "MM") & Text(TODAY(), "DD") & Text(TODAY(), "yyyy")) & "-" . iVal
这是基于日期的记录自动入罪。这是整个代码:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 6 Then
Application.EnableEvents = False
Target.Offset(0, 2).Value = Date
Target.Offset(0, 4).Value = "Open"
Dim iVal As Integer
iVal = Application.WorksheetFunction.CountIf(Range("H1:H5000"), Date)
Target.Offset(0, -4).Value = (Text(TODAY(), "MM") & Text(TODAY(), "DD") & Text(TODAY(), "yyyy")) & "-" . iVal
Application.EnableEvents = True
End If
End Sub
答案 0 :(得分:1)
格式化文本的功能是FORMAT,而today()的功能是Date。 示例如下:
format(Date,"ddmmyyyy")
这应该可以解决你的问题=] 我认为你的意思是
& iVal
而不是
. iVal
最后?
答案 1 :(得分:1)
这对你有用......我假设专栏
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 6 Then
Application.EnableEvents = False
Target.Offset(0, 2).Value = Date
Target.Offset(0, 4).Value = "Open"
**Dim iVal As Integer
iVal = Application.WorksheetFunction.CountIf(Range("H1:H5000"), Date)
Target.Offset(0, -4).Value = Format(Date, "mmddyy") & "-" & Format(iVal, "000")**
Application.EnableEvents = True
End If
End Sub