Posted to microsoft.public.excel.programming
|
|
Repost: Looking for info on how to program a userform to use filters
Here is some background reading:
http://www.microsoft.com/ExcelDev/Articles/sxs11pt1.htm
Lesson 11: Creating a Custom Form
Excerpted from Microsoft® Excel 97 Visual Basic® Step by Step.
http://support.microsoft.com/default.aspx?kbid=161514
XL97: How to Use a UserForm for Entering Data
http://support.microsoft.com/default.aspx?kbid=213749
XL2000: How to Use a UserForm for Entering Data
http://support.microsoft.com/?id=168067
XL97: WE1163: "Visual Basic Examples for Controlling UserForms"
--
Regards,
Tom Ogilvy
Bruccce wrote in message
news:BqcYa.81483$uu5.8747@sccrnsc04...
Tom, what I am looking for, is basically a userform with the button
functions similair to what you can create with "Forms" off of the data
menu.
I also need more functionality (most of the unique stuff, I already have
gotten to work - dialer, email, etc...) but what I consider to be the
BASIC
stuff, I have not been able to get to work correctly together...
I hope this helps a little.
Bruce
"Bruccce" wrote in message
news:R0cYa.81086$Ho3.11387@sccrnsc03...
Tom,
Please bear with my ignorance...
What is a datatable and what is a selection?
How can I tell which is which?
I just have not been able to get the full grasp of the VB language! I
have
done a LOT of programming in dbase etc SO MUCH DIFFERENT!
Thanks,
Bruce
"Tom Ogilvy" wrote in message
...
Using selection would be problematic, if the selection isn't in the
data
that is to be filtered.
You can correct this by directly refering to the datatable rather than
using
selection.
Assume your data table is in A1:Z50
Private Sub Commandbutton1_Click()
Dim rng as Range
if Activesheet.AutofilterMode then
set rng = Activesheet.AutoFilter.Range
Else
set rng = Range("A1").CurrentRegion
End if
rng.AutoFilter Field:=7, Criteria1:="0"
rng.AutoFilter Field:=10, Criteria1:="Voice Drop"
End Sub
--
Regards,
Tom Ogilvy
"Bruccce" wrote in message
news:d18Ya.80228$o%2.35978@sccrnsc02...
On my userform, I have a next/prev button, and when I use these, it
goes
to
the next record that is in the worksheet, not the "filter" set
Bruce
"Tom Ogilvy" wrote in message
...
Code works on the active sheet - not sure what you mean by
navigation.
Regards,
Tom Ogilvy
"Bruccce" wrote in message
news:yR_Xa.50867$cF.18912@rwcrnsc53...
Tom,
This, in concept, is what I thought should work. but when I try
it,
ALL
records are still shown.
Could this possibly be be cause of my navigation, loading of the
userform?
Bruce
"Tom Ogilvy" wrote in message
...
Private Sub Commandbutton1_Click()
if Activesheet.AutofilterMode then
Activesheet.AutoFilter.Range.Select
Else
Range("A1").CurrentRegion.Select
End if
Selection.AutoFilter Field:=7, Criteria1:="0"
Selection.AutoFilter Field:=10, Criteria1:="Voice Drop"
End Sub
Regards,
Tom Ogilvy
Bruccce wrote in message
news:_cUXa.71967$Ho3.9474@sccrnsc03...
What you mean by filter is not very clear. Are you
trying
to
filter
information shown in a listbox on the form or use the form
to
get
setttings
for an autofilter (as an example) on a worksheet?
What I want to do, is to look at only certain sets of
information
while
I
am
using my form.
Example:
I am calling people, nationwide. I might want to set it
where
I
am
only
seeing people in MY timezone, that I have not talked to yet.
Columns that I would create an autofilter on would be
timezone
and
call
results
Here is a filter that works while in the spreadsheet:
Sub TimeZoneVoiceDrop()
'
' TimeZoneVoiceDrop Macro
' Macro recorded 8/5/2003 by Bruce
'
'
Selection.AutoFilter
ActiveWindow.ScrollColumn = 61
ActiveWindow.ScrollColumn = 56
ActiveWindow.ScrollColumn = 54
ActiveWindow.ScrollColumn = 53
ActiveWindow.ScrollColumn = 51
ActiveWindow.ScrollColumn = 50
ActiveWindow.ScrollColumn = 48
ActiveWindow.ScrollColumn = 47
ActiveWindow.ScrollColumn = 46
ActiveWindow.ScrollColumn = 45
ActiveWindow.ScrollColumn = 44
ActiveWindow.ScrollColumn = 43
ActiveWindow.ScrollColumn = 42
ActiveWindow.ScrollColumn = 41
ActiveWindow.ScrollColumn = 39
ActiveWindow.ScrollColumn = 38
ActiveWindow.ScrollColumn = 36
ActiveWindow.ScrollColumn = 35
ActiveWindow.ScrollColumn = 32
ActiveWindow.ScrollColumn = 31
ActiveWindow.ScrollColumn = 29
ActiveWindow.ScrollColumn = 28
ActiveWindow.ScrollColumn = 27
ActiveWindow.ScrollColumn = 25
ActiveWindow.ScrollColumn = 24
ActiveWindow.ScrollColumn = 23
ActiveWindow.ScrollColumn = 22
ActiveWindow.ScrollColumn = 21
ActiveWindow.ScrollColumn = 17
ActiveWindow.ScrollColumn = 16
ActiveWindow.ScrollColumn = 15
ActiveWindow.ScrollColumn = 14
ActiveWindow.ScrollColumn = 13
ActiveWindow.ScrollColumn = 12
ActiveWindow.ScrollColumn = 11
ActiveWindow.ScrollColumn = 10
ActiveWindow.ScrollColumn = 9
ActiveWindow.ScrollColumn = 8
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
Selection.AutoFilter Field:=7, Criteria1:="0"
Selection.AutoFilter Field:=10, Criteria1:="Voice Drop"
End Sub
And it only shows 13 records with my current data set.
However, when I launch my userform, it show ALL records. It
does
not
pay
attention to any filters I have in place. I have tried to
assign
the
filtermacro to a user button, but that did not help
either....
I hope this is clearer than mud...
Bruce
"Tom Ogilvy" wrote in message
...
http://www.microsoft.com/ExcelDev/Articles/sxs11pt1.htm
Lesson 11: Creating a Custom Form
Excerpted from Microsoft® Excel 97 Visual Basic® Step by
Step.
http://support.microsoft.com/default.aspx?kbid=161514
XL97: How to Use a UserForm for Entering Data
http://support.microsoft.com/default.aspx?kbid=213749
XL2000: How to Use a UserForm for Entering Data
What you mean by filter is not very clear. Are you trying
to
filter
information shown in a listbox on the form or use the form
to
get
setttings
for an autofilter (as an example) on a worksheet?
Regards,
Tom Ogilvy
"Bruccce" wrote in message
news:uJRXa.72449$YN5.55027@sccrnsc01...
I am trying to create a userform that I can set filters
in.
I
am
looking
for
how to do this.
I have tried creating a macro that sets the filter I
want,
and
put
it
in
the
userform, and assigned this to a button, but userform
does
not
seem
to
recognize the filter. It still shows every record. What
am
I
doing
wrong
Where can I find this info? (I have several books, but I
can
not
find
this
combination covered....)
I have had somebody create a userform for me, but I need
to
change
the
filter, and I need to change a lot of other items about
the
form,
so
I
want
to basically start from scratch.
I would like to LEARN how to do this so I can maintain
my
own
code.
thanks
Bruce
|