EXCEL 送货单问题

我要设置在点击’送货单打印‘后自动保存到’送货单记录‘工作簿里面,现在的源文档问题是保存不了,,每次删除完’送货单记录‘里面后,再次保存还是会出现7条不规则的记录,,请高手帮忙!!!
宏代码是:

Sub 送货1打印()
Application.Dialogs(xlDialogPrinterSetup).Show
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate _
:=True '打印当前第一页
'Sheets(1).Range("B3") = Sheets(1).Range("B3").Value + 1 页码引用单元c1的数值增加1
'ThisWorkbook.Save 保存工作簿
Dim fname As String
fname = Range("b3")
Dim cname As String
cname = Range("g4")
With ActiveWorkbook.PublishObjects("xiahong_1239")
.HtmlType = xlHtmlStatic
.Filename = "E:\佳明翔送货单记录\" & fname & "-" & cname & ".png"

.Publish (False)
.AutoRepublish = False
End With
[b3] = [b3] + 1

Dim x As Long, y As Byte
x = Sheets("送货单记录").[B65536].End(3).Row
y = [MAX(IF($a$5:$a$15<>"",ROW($a$5:$a$15)))]
Sheets("送货单记录").Range("B" & x + 1 & ":B" & x + y - 8).Value = Range("F3").Value
Sheets("送货单记录").Range("C" & x + 1 & ":C" & x + y - 8).Value = Range("B6").Value
Sheets("送货单记录").Range("D" & x + 1 & ":D" & x + y - 8).Value = Range("B3").Value
Sheets("送货单记录").Range("F" & x + 1 & ":F" & x + y - 8).Value = Range("F7").Value
Sheets("送货单记录").Range("E" & x + 1 & ":E" & x + y - 8).Value = Range("F6").Value
Sheets("送货单记录").Range("G" & x + 1 & ":G" & x + y - 8).Value = Range("H9:H" & y).Value
Sheets("送货单记录").Range("H" & x + 1 & ":H" & x + y - 8).Value = Range("A9:B" & y).Value
Sheets("送货单记录").Range("I" & x + 1 & ":I" & x + y - 8).Value = Range("B9:C" & y).Value
Sheets("送货单记录").Range("J" & x + 1 & ":J" & x + y - 8).Value = Range("C9:D" & y).Value
Sheets("送货单记录").Range("K" & x + 1 & ":K" & x + y - 8).Value = Range("D9:E" & y).Value
Sheets("送货单记录").Range("L" & x + 1 & ":L" & x + y - 8).Value = Range("E9:F" & y).Value
Sheets("送货单记录").Range("M" & x + 1 & ":M" & x + y - 8).Value = Range("F9:G" & y).Value
Sheets("送货单记录").Range("A" & x + 1 & ":A" & x + y - 8).Value = "=Row()-1"
Sheets("送货单记录").Range("A" & x + 1 & ":A" & x + y - 8).Value = Sheets("送货单记录").Range("A" & x + 1 & ":A" & x + y - 8).Value

End Sub

源文件:http://pan.baidu.com/s/1mgtCjIK

Sub 送货1打印()
Application.Dialogs(xlDialogPrinterSetup).Show
    ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate _
        :=True                        '打印当前第一页
'Sheets(1).Range("B3") = Sheets(1).Range("B3").Value + 1    页码引用单元c1的数值增加1
'ThisWorkbook.Save 保存工作簿
Dim fname As String
fname = Range("b3")
Dim cname As String
cname = Range("g4")
 With ActiveWorkbook.PublishObjects("xiahong_1239")
        .HtmlType = xlHtmlStatic
        .Filename = "E:\佳明翔送货单记录\" & fname & "-" & cname & ".png"
        
        .Publish (False)
        .AutoRepublish = False
End With
[b3] = [b3] + 1
Dim x As Long, y As Byte
x = Sheets("送货单记录").[B65536].End(3).Row
y = [MAX(IF($B$5:$B$15<>"",ROW($a$5:$a$15)))]
Sheets("送货单记录").Range("B" & x + 1 & ":B" & x + y - 8).Value = Range("F3").Value
Sheets("送货单记录").Range("C" & x + 1 & ":C" & x + y - 8).Value = Range("B6").Value
Sheets("送货单记录").Range("D" & x + 1 & ":D" & x + y - 8).Value = Range("B3").Value
Sheets("送货单记录").Range("F" & x + 1 & ":F" & x + y - 8).Value = Range("F7").Value
Sheets("送货单记录").Range("E" & x + 1 & ":E" & x + y - 8).Value = Range("F6").Value
Sheets("送货单记录").Range("G" & x + 1 & ":G" & x + y - 8).Value = Range("H9:H" & y).Value
Sheets("送货单记录").Range("H" & x + 1 & ":H" & x + y - 8).Value = Range("A9:B" & y).Value
Sheets("送货单记录").Range("I" & x + 1 & ":I" & x + y - 8).Value = Range("B9:C" & y).Value
Sheets("送货单记录").Range("J" & x + 1 & ":J" & x + y - 8).Value = Range("C9:D" & y).Value
Sheets("送货单记录").Range("K" & x + 1 & ":K" & x + y - 8).Value = Range("D9:E" & y).Value
Sheets("送货单记录").Range("L" & x + 1 & ":L" & x + y - 8).Value = Range("E9:F" & y).Value
Sheets("送货单记录").Range("M" & x + 1 & ":M" & x + y - 8).Value = Range("F9:G" & y).Value
Sheets("送货单记录").Range("A" & x + 1 & ":A" & x + y - 8).Value = "=Row()-1"
Sheets("送货单记录").Range("A" & x + 1 & ":A" & x + y - 8).Value = Sheets("送货单记录").Range("A" & x + 1 & ":A" & x + y - 8).Value
End Sub 
把Y值由A列判断改成B列判断看看,不知道其他地方有问题吗,你试试看吧追问

复制您的代码,语法错误

追答

不会吧,我电脑上执行不了,只是把Y值哪一行由a改成B,你在你原来的基础上只改这一句试试

追问

就显示一条,一直都只显示一条,您能下载原文件帮忙修改一下吗??

温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-03-13
粗看了一下你的文件,发现你的送货单的格式肯定被改动过,只要恢复原样就可以了。另外根据你的代码来看,送货单里的序号要根据右边是否有数字来填,如果右边为空,则不要填序号了。
相似回答