修改了程序,是不是这样?试一下。
Private Sub Worksheet_Change(ByVal Target As Range)
H = Target.Row: L = Target.Column
Hs = 3: He = Cells(60000, 3).End(xlUp).Row
If He < Hs Then
He = Hs
Else
He = He + 1
End If
Lb = 11
Columns("D:D").NumberFormatLocal = "yyyy/m/d h:mm;@"
Columns("B:B").NumberFormatLocal = "@"
If Hs <= H And H <= He And L = Lb Then
If H = Hs Then
If Cells(H, 1) = "" Then Cells(H, 1) = 1
If Cells(H, 2) = "" Then Cells(H, 2) = "00001"
If Cells(H, 3) = "" Then Cells(H, 3).Select
If Cells(H, 4) = "" Then Cells(H, 4) = Now
Else
If Cells(H, 1) = "" Then Cells(H, 1) = H - Hs + 1
If Cells(H, 3) = "" Or (Cells(H, 3) = Cells(H - 1, 3)) Then
Cells(H, 2) = Cells(H - 1, 2)
For LL = 3 To 9
Cells(H, LL) = Cells(H - 1, LL)
Next
Else
编号 = Val(Cells(H - 1, 2))
For I = 1 To 5 - Len(LTrim(Str$(编号)))
订单编号 = 订单编号 + "0"
Next
订单编号 = 订单编号 + LTrim(Str$(编号 + 1))
Cells(H, 2) = 订单编号
Cells(H, 4) = Now
End If
End If
End If
End Sub
把sheet1发过来,我试验一下,今晚不一定能完成,请理解
发邮箱:xymath@qq.com
给我发邮件吧!我来帮你:
ouyangff@qq.com