airforceone
Board Regular
- Joined
- Feb 14, 2022
- Messages
- 215
- Office Version
- 2019
- 2016
- Platform
- Windows
Good Day Mate,
Got my main workbook and running workbook, updating the main workbook with the following code and works fine then calling removeduplicate module to remove any duplicate record if any!
my query is, if I may? is there a way to test my Control Number before appending the running workbook to my main workbook to eliminate calling my RemoveDuplicate Module?
Got my main workbook and running workbook, updating the main workbook with the following code and works fine then calling removeduplicate module to remove any duplicate record if any!
VBA Code:
Workbooks.Open ThisWorkbook.Path & "\CONSO.xlsx"
Set wsTarget = ActiveWorkbook.Worksheets("TARGET")
Set wsSource = ThisWorkbook.Worksheets("SOURCE")
ColSource = wsSource.Cells(1, Columns.count).End(xlToLeft).Column
LColChar = Split(Cells(1, ColSource).Address, "$")(1)
lrSource = wsSource.Cells(wsSource.Rows.count, "A").End(xlUp).Row
lrTarget = wsTarget.Cells(wsTarget.Rows.count, "A").End(xlUp).Offset(1).Row
wsSource.Range("A2:" & LColChar & lrSource).Copy wsTarget.Range("A" & lrTarget)
wsTarget.Parent.Close True
Set wsSource = Sheets("CURRENT")
lrSource = wsSource.Range("A" & Rows.count).End(xlUp).Row
For ctrLoop = 2 To lrSource
wsSource.Range("A1:AN" & lrSource).RemoveDuplicates Columns:=Array(1, 2, 3), Header:=xlYes
Next
my query is, if I may? is there a way to test my Control Number before appending the running workbook to my main workbook to eliminate calling my RemoveDuplicate Module?