Little help with filter Please please!

J

James8309

Hi,

I am trying to do an advance filter in VBA. I do not understand why it
is creating a "reference error" I am just trying to paste the unique
advanced filter result to the very last row + 1 on column A. Can
anyone help? Thanks alot!


Sub Testing()

Dim LR as Integer
Dim LR1 as Integer
Dim Range123 as Range

LR = Range("A65000").End(xlUp).Row
LR1 = LR + 1

Set Range123 = Sheets("Sheet1").Range("A2:A" & LR)
Range123.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=("A" &
LR1 _
), Unique:=True

End Sub

Regards

Jay
 
K

kg_singapore

Where do you want the results to be placed,

one row below
or
one column right

In your code, you are trying place next row. Pl chk this

regards
KarthiGanesh
 
Joined
Jun 4, 2008
Messages
15
Reaction score
0
Sub Testing()

Dim LR As Integer
Dim LR1 As Integer
Dim Range123 As Range

LR = Range("A65000").End(xlUp).Row
LR1 = LR + 1

Set Range123 = Sheets("Sheet1").Range("A2:A" & LR1)
Range123.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("A" & LR1), Unique:=True

End Sub
 
J

James8309

Where do you want the results to be placed,

 one row below
or
one column right

In your code, you are trying place next row.  Pl chk this

regards
KarthiGanesh











- Show quoted text -

One row below the Last row. Why is it keep returning "Reference
error"?

Can you help?

Thx
 
K

Karthi Ganesh

Did you check that there are sufficient rows below the last row of your data?
It may be one reason.
 
J

James8309

Did you check that there are sufficient rows below the last row of your data?
It may be one reason.








- Show quoted text -

Even if I do CopytoRange:=("C5") it returns the same error. column C:C
is totally empty.
 
B

Bob Phillips

Sub Testing()

Dim LR As Integer
Dim LR1 As Integer
Dim Range123 As Range

LR = Range("A65000").End(xlUp).Row
LR1 = LR + 1

Set Range123 = Sheets("Sheet1").Range("A2:A" & LR)
Range123.AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Range("A" & LR1), _
Unique:=True

End Sub



--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



Did you check that there are sufficient rows below the last row of your
data?
It may be one reason.








- Show quoted text -

Even if I do CopytoRange:=("C5") it returns the same error. column C:C
is totally empty.
 
K

Karthi Ganesh

Hi,

I think you forget to put the word range ???
Range123.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=("A" &
LR1 _
), Unique:=True

change like this
Range123.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("A" &
LR1 _
), Unique:=True

I hope you understood the error!

regards
KarthiGanesh
 
K

Karthi Ganesh

Good work Mr.Bob, you found the mistake at the first attempt.
Thanks a lot.

regards
Karthi Ganesh
 
J

James8309

Good work Mr.Bob, you found the mistake at the first attempt.
Thanks a lot.

regards
Karthi Ganesh










- Show quoted text -

omg, I am so dumb lol.

Thanks for your help guys! as always :D
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top