acotelesage
New Member
- Joined
- Feb 19, 2023
- Messages
- 1
- Office Version
- 365
- Platform
- Windows
Hello,
I am quite new to VBA and I am trying to copy and paste certain information into a database without duplicating data that's already there. There is a row in particular that I'd like my code to search for identical info and when that happens, avoid pasting.
Here is my code so far, thanks for your help :
Sub Copy_Paste_Below_Last_Cell()
Dim wsCopy As Worksheet
Dim wsDest As Worksheet
Dim lCopyLastRow As Long
Dim lDestLastRow As Long
Set wsCopy = ThisWorkbook.Worksheets("Copie des comparables")
Set wsDest = Workbooks("Registre test.xlsm").Worksheets("eval")
Workbooks("Excel test.xlsm").Worksheets("Copie des comparables").Range("B3:BC7").Copy _
lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Offset(1).Row
wsCopy.Range("B3:BC7" & lCopyLastRow).Copy
wsDest.Range("A" & lDestLastRow).PasteSpecial xlPasteValues, SkipBlanks:=True
wsDest.Activate
End Sub
I am quite new to VBA and I am trying to copy and paste certain information into a database without duplicating data that's already there. There is a row in particular that I'd like my code to search for identical info and when that happens, avoid pasting.
Here is my code so far, thanks for your help :
Sub Copy_Paste_Below_Last_Cell()
Dim wsCopy As Worksheet
Dim wsDest As Worksheet
Dim lCopyLastRow As Long
Dim lDestLastRow As Long
Set wsCopy = ThisWorkbook.Worksheets("Copie des comparables")
Set wsDest = Workbooks("Registre test.xlsm").Worksheets("eval")
Workbooks("Excel test.xlsm").Worksheets("Copie des comparables").Range("B3:BC7").Copy _
lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Offset(1).Row
wsCopy.Range("B3:BC7" & lCopyLastRow).Copy
wsDest.Range("A" & lDestLastRow).PasteSpecial xlPasteValues, SkipBlanks:=True
wsDest.Activate
End Sub