要将数据粘贴到输入的最后一行数据上?
To paste the data on the last row of data inputed?
我目前的代码可以正常工作并在复制 1 sheet 时粘贴正确的数据,但是我现在希望它从 3 个不同的 sheet 中提取数据,粘贴每个 sheet 下一个作为一个大数据集。下面是我尝试使用的代码,但是停在了 .Range(LastRow)
Sub PipelineData()
Dim Fname As String
Dim SrcWbk As Workbook
Dim DestWbk As Workbook
Set DestWbk = ThisWorkbook
Fname = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls*), *.xls*", Title:="Select a File")
If Fname = "False" Then Exit Sub
Set SrcWbk = Workbooks.Open(Fname)
On Error Resume Next
Sheets("BID").ShowAllData
Sheets("DELIVERY").ShowAllData
Sheets("Complete or Cancelled").ShowAllData
On Error GoTo 0
SrcWbk.Sheets("BID").Range("A3:AP200").Copy DestWbk.Sheets("Pipeline").Range("A1")
SrcWbk.Sheets("DELIVERY").Range("A3:AP200").Copy DestWbk.Sheets("Pipeline").Range(LastRow)
SrcWbk.Sheets("Complete or Cancelled").Range("A3:AP200").Copy DestWbk.Sheets("Pipeline").Range(LastRow)
SrcWbk.Close False
End Sub
Sub PipelineData()
Dim Fname As String
Dim SrcWbk As Workbook
Dim DestWbk As Workbook
Set DestWbk = ThisWorkbook
Fname = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls*), *.xls*", Title:="Select a File")
If Fname = "False" Then Exit Sub
Set SrcWbk = Workbooks.Open(Fname)
On Error Resume Next
Sheets("BID").ShowAllData
Sheets("DELIVERY").ShowAllData
Sheets("Complete or Cancelled").ShowAllData
On Error GoTo 0
SrcWbk.Sheets("BID").Range("A3:AP200").Copy DestWbk.Sheets("Pipeline").Range("A1")
dim lastrow as long
with DestWbk.Sheets("Pipeline")
lastrow = .cells(.rows.count, 1).end(xlup).row 'Get last row
SrcWbk.Sheets("DELIVERY").Range("A3:AP200").Copy .Range("A" & LastRow)
lastrow = .cells(.rows.count, 1).end(xlup).row 'Get new last row
SrcWbk.Sheets("Complete or Cancelled").Range("A3:AP200").Copy .Range("A" & LastRow)
end with
SrcWbk.Close False
End Sub
我目前的代码可以正常工作并在复制 1 sheet 时粘贴正确的数据,但是我现在希望它从 3 个不同的 sheet 中提取数据,粘贴每个 sheet 下一个作为一个大数据集。下面是我尝试使用的代码,但是停在了 .Range(LastRow)
Sub PipelineData()
Dim Fname As String
Dim SrcWbk As Workbook
Dim DestWbk As Workbook
Set DestWbk = ThisWorkbook
Fname = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls*), *.xls*", Title:="Select a File")
If Fname = "False" Then Exit Sub
Set SrcWbk = Workbooks.Open(Fname)
On Error Resume Next
Sheets("BID").ShowAllData
Sheets("DELIVERY").ShowAllData
Sheets("Complete or Cancelled").ShowAllData
On Error GoTo 0
SrcWbk.Sheets("BID").Range("A3:AP200").Copy DestWbk.Sheets("Pipeline").Range("A1")
SrcWbk.Sheets("DELIVERY").Range("A3:AP200").Copy DestWbk.Sheets("Pipeline").Range(LastRow)
SrcWbk.Sheets("Complete or Cancelled").Range("A3:AP200").Copy DestWbk.Sheets("Pipeline").Range(LastRow)
SrcWbk.Close False
End Sub
Sub PipelineData()
Dim Fname As String
Dim SrcWbk As Workbook
Dim DestWbk As Workbook
Set DestWbk = ThisWorkbook
Fname = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls*), *.xls*", Title:="Select a File")
If Fname = "False" Then Exit Sub
Set SrcWbk = Workbooks.Open(Fname)
On Error Resume Next
Sheets("BID").ShowAllData
Sheets("DELIVERY").ShowAllData
Sheets("Complete or Cancelled").ShowAllData
On Error GoTo 0
SrcWbk.Sheets("BID").Range("A3:AP200").Copy DestWbk.Sheets("Pipeline").Range("A1")
dim lastrow as long
with DestWbk.Sheets("Pipeline")
lastrow = .cells(.rows.count, 1).end(xlup).row 'Get last row
SrcWbk.Sheets("DELIVERY").Range("A3:AP200").Copy .Range("A" & LastRow)
lastrow = .cells(.rows.count, 1).end(xlup).row 'Get new last row
SrcWbk.Sheets("Complete or Cancelled").Range("A3:AP200").Copy .Range("A" & LastRow)
end with
SrcWbk.Close False
End Sub