当我按下保存数据库button(macros)时如何在一个Excel Sheet1中自动填充字段到另一个Sheet2?

这里是我的问题我有一个macros的VBA程序从源,这有助于自动复制一个Sheet1(模板)![在这里input图像] [1]到Sheet2(Tracker)如果我按下提交button(macros命令button)的数据。 但是,在sheet2中的数据错位请帮我macros代码如下。

Option Explicit Sub UpdateLogWorksheet() Dim historyWks As Worksheet Dim inputWks As Worksheet Dim nextRow As Long Dim oCol As Long Dim myRng As Range Dim myCopy As String Dim myCell As Range 'cells to copy from Input sheet - some contain formulas myCopy = "E7,E9,E11,E13,E15,E17,E19,E21,E23,E25,E27,E29,E31" Set inputWks = Worksheets("Input") Set historyWks = Worksheets("running R202") With historyWks nextRow = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0).Row End With With inputWks Set myRng = .Range(myCopy) If Application.CountA(myRng) <> myRng.Cells.Count Then MsgBox "Please fill in all the cells!" Exit Sub End If End With With historyWks With .Cells(nextRow, "A") .Value = Now .NumberFormat = "general" End With .Cells(nextRow, "B").Value = Application.UserName oCol = 3 For Each myCell In myRng.Cells historyWks.Cells(nextRow, oCol).Value = myCell.Value oCol = oCol + 1 Next myCell End With 'clear input cells that contain constants With inputWks On Error Resume Next With .Range(myCopy).Cells.SpecialCells(xlCellTypeConstants) .ClearContents Application.GoTo .Cells(1) ', Scroll:=True End With On Error GoTo 0 End With End Sub 

感谢和问候,Sreenivasulu。