Forum Discussion
VBA - Transferring select data to new spreadsheet
- Jul 08, 2020Oops! You're right, it is the same as the original, not sure how I managed that.... So, below should be the alternative code - try this and let me know how it works out for you. Sub Export_Details() Dim wb As Workbook 
 Dim rTable As RangeThisWorkbook.Worksheets("Source").Activate 
 ActiveSheet.UsedRange.AutoFilter Field:=1, Criteria1:="Yes"
 Set rTable = Sheets("Source").AutoFilter.Range
 Set rTable = rTable.Resize(rTable.Rows.Count - 1)
 Set rTable = rTable.Offset(1)
 rTable.CopySet wb = Workbooks.Open("C:\Users\Sslack\Desktop\Transfer Data.xlsm") 
 wb.Worksheets("data").Activatelastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row ActiveSheet.Cells(lastrow + 1, 1).Select ActiveSheet.Paste 
 ActiveWorkbook.SaveActiveWorkbook.Close savechanges = True Set wb = Nothing ThisWorkbook.Worksheets("Source").Activate 
 Application.CutCopyMode = False
 ActiveSheet.AutoFilterMode = False
 ThisWorkbook.Worksheets("Source").Cells(1, 1).SelectEnd Sub 
Hi Charla74,
Yes, I've downloaded the workbook a couple of times and tried it. It still only transfers 'Row 12' as it did previously.
Also, the code in your message is the same code i had in the original workbook.
Maybe the changes didn't save?
Oops! You're right, it is the same as the original, not sure how I managed that....
So, below should be the alternative code - try this and let me know how it works out for you.
Sub Export_Details()
Dim wb As Workbook
Dim rTable As Range
ThisWorkbook.Worksheets("Source").Activate
ActiveSheet.UsedRange.AutoFilter Field:=1, Criteria1:="Yes"
Set rTable = Sheets("Source").AutoFilter.Range
Set rTable = rTable.Resize(rTable.Rows.Count - 1)
Set rTable = rTable.Offset(1)
rTable.Copy
Set wb = Workbooks.Open("C:\Users\Sslack\Desktop\Transfer Data.xlsm")
wb.Worksheets("data").Activate
lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
ActiveSheet.Cells(lastrow + 1, 1).Select
ActiveSheet.Paste
ActiveWorkbook.Save
ActiveWorkbook.Close savechanges = True
Set wb = Nothing
ThisWorkbook.Worksheets("Source").Activate
Application.CutCopyMode = False
ActiveSheet.AutoFilterMode = False
ThisWorkbook.Worksheets("Source").Cells(1, 1).Select
End Sub