Below is the VBScript code for deleting the duplicates from one excel workbook and then copying it to another, when I run it I'm getting an error;
Object required:Activesheet
This is the code:
Set objExcel = CreateObject("Excel.Application")
' Open the workbook
Set objWorkbook1 = objExcel.Workbooks.Open("C:UsersvijendraDesktopduplicates.xlsx")
Macro
Sub Macro1()
activesheet.UsedRange.RemoveDuplicates Columns=Array(), Header=xlYes
End Sub
'Opening the 2nd workbook
Set objworkbook2 = objExcel.Workbooks.Open("C:UsersvijendraDesktopest2.xlsx")
'Set to True or False, whatever you like
objExcel.Visible = True
'Select the range on Sheet1 you want to copy
objWorkbook1.Worksheets("Sheet1").usedrange.Copy
'Paste it on sheet1 of workbook2, starting at A1
objWorkbook2.Worksheets("Sheet1").Range("A1").PasteSpecial
'Activate Sheet2 so you can see it actually pasted the data
objWorkbook2.Worksheets("Sheet1").Activate
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…