|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 保存1()
ActiveSheet.PageSetup.PrintArea = "$A$1:$k$17"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
With Sheets("订单汇总")
r = .[A65536].End(xlUp).Row + 2
.Cells(r, 1).Value = Range("j4").Value
.Cells(r, 2).Value = Range("j3").Value
.Cells(r, 3).Value = Range("c3").Value
.Cells(r, 4).Value = Range("b7").Value
.Cells(r, 5).Value = Range("e7").Value
.Cells(r, 6).Value = Range("f7").Value
.Cells(r, 7).Value = Range("g7").Value
.Cells(r, 8).Value = Range("h7").Value
.Cells(r, 9).Value = Range("c7").Value
.Cells(r, 10).Value = Range("c13").Value
.Cells(r, 11).Value = Range("k7").Value
.Cells(r, 11).Value = Range("f3").Value
n = Right(.Cells(.[A65536].End(xlUp).Row, 2), 3) + 1
End With
Range("j3").Value = Year(Date) & Format(322, "0000") & Format(n, "000")
End Sub
Sub 保存2()
Dim Sht1 As Worksheet, Sht As Worksheet
Dim Myr1%, Myr%, n%, m%, x%
Application.ScreenUpdating = False
Set Sht1 = Sheets("订单汇总")
Sht1.Activate
i = Application.CountA(Sheets(1).Range("a:a"))
For Each Sht In Sheets
If Sht.Name <> Sht1.Name Then
Myr1 = Sht1.[A65536].End(xlUp).Row + 2
Myr = Sht.[c65536].End(xlUp).Row - 2
n = Myr - 7
Cells(Myr1, 1).Resize(n, 1) = Sht.[j4]
Cells(Myr1, 2).Resize(n, 1) = Sht.[j3]
Cells(Myr1, 3).Resize(n, 1) = Sht.[c3]
Sht.Range("a7:k" & n + 6).Copy
Cells(Myr1, 4).Select
Selection.PasteSpecial Paste:=xlPasteValues
Cells(Myr1, 15).Resize(n, 1) = Sht.[f3]
Cells(Myr1, 16).Resize(n, 1) = Sht.[c14]
m = Sht.[A65536].End(xlUp).Row - 16
Sht.[j3] = Year(Date) & Format(322, "0000") & Format(m, "000")
End If
Next Sht
Range("a" & i).Select
Application.ScreenUpdating = True
End Sub
保存1代码能实现单号自动加1位,但就是订单只有第一行能够保存到汇总表,下面的5行都不能存到汇总表,保存2代码能实现订单第1-5能够保存到汇总表,但不能实现单号自动加1位,请版主帮我修改红色部分代码,这部分代码是用于打印一次单号自动加1位,现在的代码不能单号自动加1位。也可以直接修改成你的代码,但是必须要能实现单号自动加1位
[ 本帖最后由 lbl016 于 2010-4-18 09:19 编辑 ] |
|