Hi There,
I'm currently trying to send a range of data from a worksheet to another worksheet in a different workbook. However the code I'm using is only sending the top row, is it possible to send all rows?
I'm also trying to avoid sending duplicates. So if there is a matching row in the workbook it's being sent to the information won't be sent again.
The code I'm using is:
Sub Copy_To_Another_Workbook()
Dim SourceRange As Range
Dim DestRange As Range
Dim DestWB As Workbook
Dim DestSh As Worksheet
Dim Lr As Long
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
If bIsBookOpen_RB("mastersheet.xls") Then
Set DestWB = Workbooks("mastersheet.xls")
Else
Set DestWB = Workbooks.Open("C:\Users\Name\Desktop\New folder\mastersheet.xlsm")
End If
Set SourceRange = ThisWorkbook.Sheets("withdrawnsheet").Range("A2:T2")
Set DestSh = DestWB.Worksheets("masterwithdrawn")
Lr = LastRow(DestSh)
Set DestRange = DestSh.Range("A" & Lr + 1)
With SourceRange
Set DestRange = DestRange.Resize(.Rows.Count, .Columns.Count)
End With
DestRange.Value = SourceRange.Value
DestWB.Close savechanges:=True
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
Bookmarks