I'm taking monthly exported CSVs of customer information and importing them to an existing master worksheet. The front desk staff manually copies and pastes the data into the sheet, causing tons of issues in the accuracy of the data.
I was put on the task of "simplifying it" so... I decided to make a macro that the front desk can click "update" it will pull up an explorer window, they can select a download CSV for the month, and it will simply copy the range (I have this range within the macro) in that CSV sheet and add it to the bottom of the master worksheet, adding on for the totals of that year.
Issue: the CSV I import overwrites the whole sheet that is being targeted for the paste. Any idea how to stop that?
Sub UpdateServicesData()
Dim FileToOpen As Variant
Dim OpenBook As Workbook
FileToOpen = Application.GetOpenFilename("CSV or Text Files: ,*.csv;*.txt*", , "Browse for your File to Import")
If FileToOpen <> False Then
Set OpenBook = Application.Workbooks.Open(FileToOpen)
If OpenBook.Worksheets(1).Range("A2").Value >= ThisWorkbook.Worksheets("Home").Range("C3").Value Then
OpenBook.Sheets(1).Range("A2:L10000").Copy
Workbooks("TEB.xlsm").Activate
Sheets("Services Data").Select
lrTarget = Cells.Find("*", Cells(3, 1), xlFormulas, xlPart, xlByRows, xlPrevious, False).Row
Cells(lrTarget + 1, 1).Select
ActiveSheet.PasteSpecial
Columns("A:L").AutoFit
Cells(1, 1).Select
OpenBook.Close False
End If
End If
End Sub