Excel_not_Knower
New Member
- Joined
- Jan 7, 2020
- Messages
- 6
- Office Version
- 2016
- Platform
- Windows
Hi,
I have a code which copies first column from spreadsheet and suppose to paste in master spreadsheet just below the last used row but it drops data in the end of table.
Pls can someone suggest how to make it work like I need?
It works fine when Paste range is not in table range but it's not a deal .
Table name SLJ_4
Sub Import_data()
Dim r1 As Excel.Range
Dim r2 As Excel.Range
Dim r3 As Excel.Range
Dim c As Excel.Range
Dim x As Date
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Worksheets("Export").Activate
Range("A1").CurrentRegion.RemoveDuplicates Columns:=Array(1, 10), Header:=xlYes
Worksheets("Ticksheet_1").Activate
Set r1 = Range("A1").Resize(Range("A" & Rows.Count).End(xlUp).Row)
Set r2 = Worksheets("Export").Range("A2").Resize(Worksheets("Export").Range("A" & Rows.Count).End(xlUp).Row)
x = Now
For Each c In r2
Set r3 = r1.Find(What:=c.Value, MatchCase:=False, Lookat:=xlWhole)
If r3 Is Nothing Then
Range("A" & Rows.Count).End(xlUp).Offset(1).Value = c.Value
End If
Next
Debug.Print DateDiff("s", x, Now)
Sheets("Export_Dumb1").Delete
Sheets("Export_Dumb2").Delete
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
I have a code which copies first column from spreadsheet and suppose to paste in master spreadsheet just below the last used row but it drops data in the end of table.
Pls can someone suggest how to make it work like I need?
It works fine when Paste range is not in table range but it's not a deal .
Table name SLJ_4
Sub Import_data()
Dim r1 As Excel.Range
Dim r2 As Excel.Range
Dim r3 As Excel.Range
Dim c As Excel.Range
Dim x As Date
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Worksheets("Export").Activate
Range("A1").CurrentRegion.RemoveDuplicates Columns:=Array(1, 10), Header:=xlYes
Worksheets("Ticksheet_1").Activate
Set r1 = Range("A1").Resize(Range("A" & Rows.Count).End(xlUp).Row)
Set r2 = Worksheets("Export").Range("A2").Resize(Worksheets("Export").Range("A" & Rows.Count).End(xlUp).Row)
x = Now
For Each c In r2
Set r3 = r1.Find(What:=c.Value, MatchCase:=False, Lookat:=xlWhole)
If r3 Is Nothing Then
Range("A" & Rows.Count).End(xlUp).Offset(1).Value = c.Value
End If
Next
Debug.Print DateDiff("s", x, Now)
Sheets("Export_Dumb1").Delete
Sheets("Export_Dumb2").Delete
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub