ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   browsing filter (https://www.excelbanter.com/excel-programming/383141-browsing-filter.html)

mcolson

browsing filter
 
I have a file that imports data from .xml's and .csv files. If button
1 is pressed, I only want to look for .csv and .xls files, if button 2
is pushed, in only want to look for .xml files. I am using the
following code when 1 is pressed
.Filters.Add "spreadsheet", "*.xls; *.csv", 1
When 2 is pressed I use this filter
..Filters.Add "spreadsheet", "*.xml", 1

They both run fine, until I trying running one after I just ran the
other. When I try to run the other, it uses the filter criteria I
used previously instead the of the criteria I want to use now. I have
to exit the program to get it to work. Does anyone know why this is?
Each filter is performed in separate subroutines and modules. I call
which routine to run when the button is pressed. I have verified that
the buttons are calling the correct functions.


mcolson

browsing filter
 
On Feb 13, 10:45 am, "mcolson" wrote:
I have a file that imports data from .xml's and .csv files. If button
1 is pressed, I only want to look for .csv and .xls files, if button 2
is pushed, in only want to look for .xml files. I am using the
following code when 1 is pressed
.Filters.Add "spreadsheet", "*.xls; *.csv", 1
When 2 is pressed I use this filter
.Filters.Add "spreadsheet", "*.xml", 1

They both run fine, until I trying running one after I just ran the
other. When I try to run the other, it uses the filter criteria I
used previously instead the of the criteria I want to use now. I have
to exit the program to get it to work. Does anyone know why this is?
Each filter is performed in separate subroutines and modules. I call
which routine to run when the button is pressed. I have verified that
the buttons are calling the correct functions.


It looks like I needed to add a .filters.clear to clear out the
filters first.


Tom Ogilvy

browsing filter
 
.Filters.Clear
.Filters.Add "spreadsheet", "*.xls; *.csv", 1


.Filters.Clear
.Filters.Add "spreadsheet", "*.xml", 1


--
Regards,
Tom Ogilvy


"mcolson" wrote in message
oups.com...
I have a file that imports data from .xml's and .csv files. If button
1 is pressed, I only want to look for .csv and .xls files, if button 2
is pushed, in only want to look for .xml files. I am using the
following code when 1 is pressed
.Filters.Add "spreadsheet", "*.xls; *.csv", 1
When 2 is pressed I use this filter
.Filters.Add "spreadsheet", "*.xml", 1

They both run fine, until I trying running one after I just ran the
other. When I try to run the other, it uses the filter criteria I
used previously instead the of the criteria I want to use now. I have
to exit the program to get it to work. Does anyone know why this is?
Each filter is performed in separate subroutines and modules. I call
which routine to run when the button is pressed. I have verified that
the buttons are calling the correct functions.





All times are GMT +1. The time now is 09:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com