I want to be able to select a row and copy & paste it (With a command button) to a closed workbook that remains closed. The code below copies everything below a range. I just want to copy the row I have selected.
These are the lines that need to be changed:
With ThisWorkbook.Worksheets("Sheet1")
With .Range(.Range("A4:Q4"), .Range("A4:Q4").End(xlDown))
destSht.Cells(destSht.Rows.Count, 1).End(xlUp).Offset(1).Resize(.Rows.Count, .Columns.Count).Value = .Value
The full code:
Sub copytoarchive()
Dim destSht As Worksheet
Workbooks.Open ("C:\...\FileToCopyTo.xlsx")
Set destSht = ActiveWorkbook.Worksheets("Sheet3")
With ThisWorkbook.Worksheets("Sheet1")
With .Range(.Range("A4:Q4"), .Range("A4:Q4").End(xlDown))
destSht.Cells(destSht.Rows.Count, 1).End(xlUp).Offset(1).Resize(.Rows.Count, .Columns.Count).Value = .Value
End With
End With
destSht.Parent.Close True
End Sub
These are the lines that need to be changed:
With ThisWorkbook.Worksheets("Sheet1")
With .Range(.Range("A4:Q4"), .Range("A4:Q4").End(xlDown))
destSht.Cells(destSht.Rows.Count, 1).End(xlUp).Offset(1).Resize(.Rows.Count, .Columns.Count).Value = .Value
The full code:
Sub copytoarchive()
Dim destSht As Worksheet
Workbooks.Open ("C:\...\FileToCopyTo.xlsx")
Set destSht = ActiveWorkbook.Worksheets("Sheet3")
With ThisWorkbook.Worksheets("Sheet1")
With .Range(.Range("A4:Q4"), .Range("A4:Q4").End(xlDown))
destSht.Cells(destSht.Rows.Count, 1).End(xlUp).Offset(1).Resize(.Rows.Count, .Columns.Count).Value = .Value
End With
End With
destSht.Parent.Close True
End Sub