Hello all
I have written the following code to append new data into a sheet from another sheet.
The code is as follows
I have a couple of questions
1 - Is this code acceptable or is there any improvements that could be made?
2 - I also need to tweak this code, as it now seems that some of the data that is to be brought in will not be available at the same time. Is there a simple check / count that can be used to validate each line and the number in the 3rd column, if its greater on the data that's being copied in then it gets applied and that the date matches as well
Not sure if that makes sense, I am also researching the later part so I can add more detail as I go
Cheers for any help
TC
I have written the following code to append new data into a sheet from another sheet.
The code is as follows
Code:
Sub AppendEPOS()
'
' AppendEPOS Macro
' Copy Data from the Converter into the EPOS
'
Dim wb1 As Workbook
Dim wb2 As Workbook
Dim Sheet As Worksheet
Dim PasteStart As Range
Set wb1 = ActiveWorkbook
FileToOpen = Application.GetOpenFilename _
(Title:="Please choose a Report to Parse")
If FileToOpen = False Then
MsgBox "No File Specified.", vbExclamation, "ERROR"
Exit Sub
Else
Set wb2 = Workbooks.Open(Filename:=FileToOpen)
wb2.Sheets("EPOS Sales Copy sheet").Range("A2").Select
Range(Selection, Selection.End(xlToRight)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
wb2.Close
Sheets("EPOS Sales").Select
Dim lastRow1 As Long
lastRow1 = Range("A" & Rows.Count).End(xlUp).Row
Range("A" & lastRow1 + 1).Select
Selection.Paste
Application.CutCopyMode = False
End If
Dim lastRow2 As Long
lastRow2 = Range("C" & Rows.Count).End(xlUp).Row
Range("D2:Q2").Select
Selection.AutoFill Destination:=Range("D2:Q" & lastRow2)
Calculate
Sheets("Control").Select
Range("E11").Select
ActiveCell.FormulaR1C1 = "=NOW()"
Range("E11").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End Sub
I have a couple of questions
1 - Is this code acceptable or is there any improvements that could be made?
2 - I also need to tweak this code, as it now seems that some of the data that is to be brought in will not be available at the same time. Is there a simple check / count that can be used to validate each line and the number in the 3rd column, if its greater on the data that's being copied in then it gets applied and that the date matches as well
Not sure if that makes sense, I am also researching the later part so I can add more detail as I go
Cheers for any help
TC