excel 如何用制作票据打印的编码每打印一次自动加一比如LSP201506120001,下次打印为LSP201506120002

我已经实现了重数字功能,不知道如何加入字母比如在201506120001前面加LSP,代码如下:
Sub 打印()
Dim i As Integer '
If Range("h3") = "" Then Range("h3") = 0
If Mid(Range("h3"), 7, 2) = Format(Now, "DD") Then '
i = Right(Range("h3"), 4) + 1 '
Else
i = 1
End If
Range("h3") = Format(Now, "YYYY") & Format(Now, "MM") & Format(Now, "DD") & Right("000" & i, 4)
ActiveWindow.SelectedSheets.PrintOut '打印当前页
ActiveWorkbook.Save
End Sub

以下代码手写的,错误无怪

sub test()
if [h3]="" then
  [h3]="LSP" & format(date,"yyyymmdd") & "0001"
else
  if mid([h3],4,8)<>format(date,"yyyymmdd") then
      [h3]="LSP" & format(date,"yyyymmdd") & "0001"
  else
      [h3]="LSP" & val(right([h3],12))+1
  end if
end if
activesheet.printout
end sub

追问

不行啊错误,我qq 936173592

温馨提示:答案为网友推荐,仅供参考
相似回答