I am trying to copy 2 separate columns from SHEET 1, Column B and D, and paste them to SHEET 2 but append them to data that is already present on that sheet in columns A & B.
Ultimately I have a macro that has the user open an excel file and paste that information onto SHEET 1. Throughout the day, the user must rerun the macro and I lose that information on SHEET 1. I am looking to save the initial data from SHEET 1 to SHEET 2 to create a running list of data for that day but I am struggling to figure out the VBA. Each day starts with a new document.
I want to input this code before the "Closed OB" ClearContents code.
Sub Get_Data_From_File() Dim FileToOpen As Variant Dim OpenBook As Workbook Dim sourceSheet As Worksheet Set sourceSheet = ActiveSheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.Calculation = xlCalculationManual
Sheets("Closed OB").Visible = True
Sheets("Temp Closed").Visible = True
Sheets("Closed OB").Select
Range("A:J").ClearContents
FileToOpen = Application.GetOpenFilename(Title:="Browse for your File & Import Range", FileFilter:="Excel Files (*.xls*),*xls*")
If FileToOpen <> False Then
Set OpenBook = Application.Workbooks.Open(FileToOpen)
OpenBook.Sheets(1).Range("A4:G1000").Copy
ThisWorkbook.Worksheets(3).Range("A1:G1000").Value = OpenBook.Sheets(1).Range("A4:G1000").Value
OpenBook.Sheets(1).Range("H4:H1000").Copy
ThisWorkbook.Worksheets(3).Range("J1:J1000").Value = OpenBook.Sheets(1).Range("H4:H1000").Value
OpenBook.Sheets(2).Range("A4:M1000").Copy
ThisWorkbook.Worksheets(4).Range("A2:R998").Value = OpenBook.Sheets(2).Range("A4:M1000").Value
OpenBook.Close False
End If
ThisWorkbook.Worksheets("Closed OB").Range("G1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.TextToColumns Destination:=Range("G1"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1), Array(3, 1)), TrailingMinusNumbers:=True
LastRow = Sheets(4).UsedRange.SpecialCells(xlCellTypeLastCell).Row
Sheets("Temp Closed").Select
With Range("D2:D" & LastRow)
.NumberFormat = General
.Value = .Value
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End With
Sheets("Closed OB").Visible = False
Sheets("Temp Closed").Visible = False
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.Calculation = xlCalculationAutomatic
Call sourceSheet.Activate
End Sub