jeremiah_j2k
New Member
- Joined
- Oct 16, 2014
- Messages
- 32
Hello,
Need some advise and your expertise to modify my macro so it will add the imported data after the last entry on my existing table. currently, the code copy and paste the data to row 2 of the Database sheet but I am keeping records to that table would just like to update it instead of overwriting the data that i have. Can you advise how to make the macro add the imported data to the last row of the Database sheet? Thanks in advance for your help.
Need some advise and your expertise to modify my macro so it will add the imported data after the last entry on my existing table. currently, the code copy and paste the data to row 2 of the Database sheet but I am keeping records to that table would just like to update it instead of overwriting the data that i have. Can you advise how to make the macro add the imported data to the last row of the Database sheet? Thanks in advance for your help.
VBA Code:
Sub Import_RAW()
Application.ScreenUpdating = False
'Selection.AutoFilter
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False
.ButtonName = "Import"
.Filters.Clear
'.Filters.Add "Excel Files", "*.csv"
'.Filters.Add "CSV File", "*.xlsx"
.Title = "Ticket Rating"
.Show
If .SelectedItems.Count Then
strFileSelected = .SelectedItems(1)
Else
'MsgBox "Cancelled by user!"
Exit Sub 'Ideally, should exit from the bottom of the sub-routine.
End If
End With
'Worksheets("Database").Range("A2:q10000").ClearContents
Range("AD1").Value = VBA.FileDateTime(strFileSelected) '& " +8 GMT"
fncFileSelected = strFileSelected
With Workbooks.Open(Filename:=fncFileSelected, ReadOnly:=True)
.Sheets(1).Cells(1).End(xlToRight).Offset(, 2).Resize(, 17).Value = ThisWorkbook.Worksheets("Database").Range("A1:q1").Value
.Sheets(1).Cells(1).CurrentRegion.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=.Sheets(1).Cells(1).End(xlToRight).Offset(, 2).CurrentRegion, Unique:=False
With .Sheets(1).Cells(1).End(xlToRight).Offset(, 2).CurrentRegion
ThisWorkbook.Worksheets("Database").Range("A1:q1").Resize(.Rows.Count, .Columns.Count).Value = .Value
ActiveWorkbook.RefreshAll
End With
Workbooks(.Name).Close 0
ActiveWorkbook.RefreshAll
End With
End Sub