yes,but........
I am not a
vb expert and I am having difficulties with the code.
I will try to explain: I have a form that you enter txtbegindate and
txtenddate. I also have "checkboxes" to even further limit the data
requested. The checkboxes are, for example:
apple total
orange total
fruit total
So if I selected a date range between 01/01/2006 and 02/01/2006 and checked
ONLY orange total and fruit total I would like the results sheet to look
something like
date orange total fruit total
01/01/2006 300 800
01/02/2006 100 500
......
02/02/2006 400 600
thanks again for you help. I have been looking around for examples and I am
coming up empty?
"Die_Another_Day" wrote:
The advantage of AutoFilter is speed. You can loop through all the used
cells fairly easily too.
Dim lRow as Long 'Last Row
Dim cnt as Long
lRow = Sheets("Summary").Range("A" &
Sheets("Summary").Rows.Count).End(xlUp)
For cnt = 1 to lRow
If Range("A" & cnt) = 'YourCriteria' Then
'Your Code
End If
Next
Is that what you were after?
Charles
Mona wrote:
charles-
thanks so much.
Is there another way to accomplish this without using the Filter option.
The filter option works OK but I have a lot of criteria on the form (check
boxes) that will also affect the data range. I did not mention because I
thought I could get started with some basic code and then add to it.
thanks!
"Die_Another_Day" wrote:
Try this and let me know if you have problems:
' Code written 8/24/2006 by CChickering for Mona
Sheets("summary").Range("A1").AutoFilter Field:=1, Criteria1:="="
& UserForm1.TxtBox1, _
Operator:=xlAnd, Criteria2:="<=" & UserForm1.TxtBox2
Sheets("summary").Range("A1").CurrentRegion.Specia lCells(xlCellTypeVisible).Copy
_
Sheets("results").Range("A1")
Sheets("summary").Range("A1").AutoFilter
Charles
Mona wrote:
I have a form created in VBA. I have a txtbox1 = begin date and txtbox2 =
end date. On this form I also have an OK button
On worksheet "summary" I have rows of data by date. Date is in A4:A500.
I would like assistance is writing the code in the "OK" procedure that will
copy data from SUMMARY based on input date range(txtbox1 and txtbox2) and
paste into worksheet "results".
thank you