G0dsreaper
New Member
- Joined
- Jan 14, 2021
- Messages
- 6
- Office Version
- 2016
- 2013
- Platform
- Windows
I need to transfer data from Activeworkbook.Sheets("Raw Data").Ranges (r1(G6:L6),r2(G12:L12),r3(G18:L18),r4(G24:L24),r5(G30:L30) to another "FileToOpen" workbook. Each range needs to transfer to the next open row of a different sheet in the filetoOpen workbook starting in column "B". i.e. R1 transfers to FileToOpen.sheets("sheet 1")Column B:F. Range 2 transfer to FileToOpen.sheets("sheet2")Column B:F and so on. In Column A I would like the date stamped in when the transfer took place.
The following code is what I have working for Copying and Pasting R1 to sheet 1 of the fileToOpen workbook. Although this just overwrites the first row with new data every time.
The following code is what I have working for Copying and Pasting R1 to sheet 1 of the fileToOpen workbook. Although this just overwrites the first row with new data every time.
VBA Code:
Sub Export_Data_To_File()
Dim FileToOpen As Variant
Dim OpenBook As Workbook
Dim lastRow As Long
Application.ScreenUpdating = False
FileToOpen = "S:\Process Engineering\Team Documents\010 Alpha\Alpha Laser Calibration\Raw Data\Raycus
Laser Decay Comparison.xlsx"
'lastRow = OpenBook.Cells(Rows.Count, "B").End(xlUp).Row + 1
If FileToOpen <> False Then
Set OpenBook = Application.Workbooks.Open(FileToOpen)
ThisWorkbook.Worksheets("Raw Data").Range("G6:L6").Copy
OpenBook.Worksheets("100% Duty Cycle").Range("B3:G3").PasteSpecial xlPasteValues
OpenBook.Worksheets("100% Duty Cycle").Range("A3") = Format(Now(), "MM-DD-YYYY")
OpenBook.Save
OpenBook.Close False
Application.ScreenUpdating = True
End If
End Sub