我已经用下面的代码来回转发了几个星期。我几乎没有什么烦恼的事。最新的奇怪之处是填充填充停止在第33行,所有原因我都看不出来。
代码:
Sub ButtonMacro()
'Hide alerts
Application.DisplayAlerts = False
'Save to users device
ChDir "U:\WINDOWS"
ActiveWorkbook.SaveAs Filename:="U:\WINDOWS\OrderForm.xlsx", FileFormat:= _
xlOpenXMLWorkbook, CreateBackup:=False
'Create new workbook and populate
Workbooks.Add
Range("A1").FormulaR1C1 = "MSG"
Range("B1").FormulaR1C1 = "=[OrderForm.xlsx]Order!R[1]C[4]"
Range("C1").FormulaR1C1 = "=[OrderForm.xlsx]Order!R[1]C[3]"
Range("D1").FormulaR1C1 = "1400008000"
Range("E1").FormulaR1C1 = "501346009175"
Range("F1").FormulaR1C1 = "=TODAY()"
Range("G1").FormulaR1C1 = "=Now()"
Selection.NumberFormat = "[$-x-systime]h:mm:ss AM/PM"
Range("A2").FormulaR1C1 = "HDR"
Range("B2").FormulaR1C1 = "C"
Range("C2").FormulaR1C1 = "1400011281"
Range("G2").FormulaR1C1 = "=[OrderForm.xlsx]Order!R[1]C[-1]"
Range("H2").FormulaR1C1 = "=[OrderForm.xlsx]Order!R[2]C[-4]"
Range("K2").FormulaR1C1 = "STD"
Range("L2").FormulaR1C1 = "=[OrderForm.xlsx]Order!R5C2"
Range("N2").FormulaR1C1 = "=[OrderForm.xlsx]Order!R7C2"
Range("O2").FormulaR1C1 = "=[OrderForm.xlsx]Order!R8C2"
Range("Q2").FormulaR1C1 = "=[OrderForm.xlsx]Order!R9C2"
Range("R2").FormulaR1C1 = "=[OrderForm.xlsx]Order!R12C2"
Range("A3").FormulaR1C1 = "POS"
Range("B3").FormulaR1C1 = "=ROW()*10-20"
Range("C3").FormulaR1C1 = "=[OrderForm.xlsx]Order!r[12]c"
Range("D3").FormulaR1C1 = "=[OrderForm.xlsx]Order!r[12]c[-3]"
Range("E3").FormulaR1C1 = "=[OrderForm.xlsx]Order!r[12]c[-3]"
Range("F3").FormulaR1C1 = "=[OrderForm.xlsx]Order!r[12]c[-1]"
Range("G3").FormulaR1C1 = "=[OrderForm.xlsx]Order!r[12]c"
Range("H3").FormulaR1C1 = "=IF(RC[-1]="""",""0"",""GBP"")"
Range("M3").FormulaR1C1 = "=COUNTIF(C[-3], ""POS"")+COUNTIF(C[-3], ""HDR"")"
'Fills column to last row of data from Cell C3
Dim LastRow As Long
LastRow = Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
Range("C3:H3" & LastRow).FillDown
'Find last blank in C and fill with TRA
Cells(Application.Evaluate("MAX(IF(C3:C2000<>"""",ROW(c3:c2000)),0,1)"), "C").Select
ActiveCell = "TRA"
'Format cells to remove 0 value
Range("A1:Z1000").Select
Range("Z1000").Activate
Selection.NumberFormat = "#;#;"
'Reinstate alerts
Application.DisplayAlerts = True
MsgBox "We have saved a copy of your order form to your computer at C:\X\X"
End Sub
这是发布脚本格式。 TRA应该填充最后一个空白单元格,但是正在查找公式,因此填充了中间页。所以这给我提出了两个问题。 1为什么它在15行之后停止,如何使它忽略其他行中的公式?我通过尚未解决的问题排在第三位,即偏移最后一行以开始填充AX(最后一行等于c的最后填充行/单元格)。如果一个线程太多,我很乐意继续研究。
这是表格的形式。灰色的“创建订单文件”按钮位于宏所在的位置。
因此,gumpf有两行,而不是实际的标题行,但是它们将始终保持不变:
一如既往地感谢您。