Thread
:
Use VBA to display record with criteria
View Single Post
#
5
Posted to microsoft.public.excel.programming
Don Guillett
external usenet poster
Posts: 10,124
Use VBA to display record with criteria
Data on sheet 1. Sheet 2 has headers on row 1 and criteria on row 2. Fire
from sheet 2
sub getdatatoothesheet()
With Sheets("sheet1")
lr = .Cells(Rows.Count, 1).End(xlUp).Row
.Range("a1:d" & lr).AutoFilter Field:=1, Criteria1:=Range("a2") ' "Apple"
.Range("a1:d" & lr).AutoFilter Field:=2, Criteria1:=Range("b2") ' "One"
.Range("a2:d" & lr).Copy Sheets("sheet2").Range("a3")
.Range("a1:d" & lr).AutoFilter
End With
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"Learn-more" wrote in message
...
I know only a little about using VBA and now have a problem not sure how to
work it out. I need to display some records in a new sheet according to
some
criteria,
Example in Sheet A
A B C D
1 Apple one Mon 1
2 Banana two Tue 2
3 Apple two Wed 5
4 Apple one Thu 6
Say I need to display in Sheet B the records that satisfy A=Apple and
B=one
and also with a total for D
I know how to use ComboBox etc to crate the list but dont know how to
make
the selection and move to a new sheet.
Can anyone tell me how or show me some web site that I can find some
examples.
Thanks so much.
Reply With Quote
Don Guillett
View Public Profile
Find all posts by Don Guillett