Rabi
05-30-2008, 02:43 AM
Hi everybody
A small piece of my following code seems plaqued with a number of errors.
Private Sub CopyUniqueVals(SrcRng As Range, DestRng As Range)
Range(SrcRng).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range(DestRng), Unique:=True
End Sub
Sub TestCopyUniqueVals()
Dim SrcRange As Range, DestRange As Range
Sheets("SubCon").Activate
' The following statement reports "Application-defined or object-defined error:
Set SrcRange = Range(ActiveSheet.Range(ListOfVendors))
' The following statement reports "Method 'Range' of object '_Global' failed:
' The Range("C4:C614") is the same as ListOfVendors named range.
Set SrcRange = Range(ActiveSheet.Range("C4:C614"))
Set DestRange = Range(Sheets("Summary").Range("A15"))
' The following statement reports "ByRef argument type mismatch":
' Even if I use the same arguments ByVal, it reports "Argument type mismatch".
Call CopyUniqueVals(SrcRange, DestRange)
End Sub
' The following procedure lists the first vendor twice whereas; others are unique:
Private Sub CopyUniqueVals2()
Sheets("SubCon").Activate
Range("C4:C614").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("Z4"), Unique:=True
End Sub
Thanks for any tip, in anticipation, for pointing out the mistakes and their remedy.
Regards,
A small piece of my following code seems plaqued with a number of errors.
Private Sub CopyUniqueVals(SrcRng As Range, DestRng As Range)
Range(SrcRng).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range(DestRng), Unique:=True
End Sub
Sub TestCopyUniqueVals()
Dim SrcRange As Range, DestRange As Range
Sheets("SubCon").Activate
' The following statement reports "Application-defined or object-defined error:
Set SrcRange = Range(ActiveSheet.Range(ListOfVendors))
' The following statement reports "Method 'Range' of object '_Global' failed:
' The Range("C4:C614") is the same as ListOfVendors named range.
Set SrcRange = Range(ActiveSheet.Range("C4:C614"))
Set DestRange = Range(Sheets("Summary").Range("A15"))
' The following statement reports "ByRef argument type mismatch":
' Even if I use the same arguments ByVal, it reports "Argument type mismatch".
Call CopyUniqueVals(SrcRange, DestRange)
End Sub
' The following procedure lists the first vendor twice whereas; others are unique:
Private Sub CopyUniqueVals2()
Sheets("SubCon").Activate
Range("C4:C614").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("Z4"), Unique:=True
End Sub
Thanks for any tip, in anticipation, for pointing out the mistakes and their remedy.
Regards,