Hey all,
The below excel macro filters and sorts data BUT when I try to export the file, all the hidden cells return, even though I want the hidden cells destroyed:
Is there a way where I can sort and filter similarly in Access but not have the issue where all the filtered fields remain when I try to export the data or perform a query against other data sets without having to worry that the filtered criteria will make its presence again?Sub Sortarific() ' ' Sort and Filter ' ' ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$E$429"), , xlNo).Name = _ "Table1" Range("Table1[#All]").Select ActiveSheet.ListObjects("Table1").TableStyle = "TableStyleLight1" ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=1, Criteria1:= _ "=Real Prop*", Operator:=xlAnd ActiveSheet.ListObjects("Table1").Range.AutoFilter Field:=2, Criteria1:= _ "=DF*", Operator:=xlAnd ActiveWorkbook.ActiveSheet.ListObjects("Table1").Sort. _ SortFields.Clear ActiveWorkbook.ActiveSheet.ListObjects("Table1").Sort. _ SortFields.Add Key:=Range("Table1[[#All],[Column5]]"), SortOn:= _ xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal With ActiveWorkbook.ActiveSheet.ListObjects("Table1"). _ Sort .Header = xlYes .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With Columns("A:B").Select Selection.EntireColumn.Hidden = True Rows("1:1").Select Range("Table1[[#Headers],[Column3]]").Activate Selection.EntireRow.Hidden = True End Sub
Thanks for response.
If you run a query in Access, you select which fields you wish to display in your query. So if there are fields in your table that you do not wish to show in the query, then you either omit them from the query or if you need them for joining to another table, you just indicate that the field should not be displayed. If you then export the query results to Excel or some other software package, it will only export the displayed fields.
Alan
Alan
Click the * below to say thanks.
Database Principles
Pivot Table Tips
Good Excel Video Tutorials
Sumifs or SumProduct
DataPig Access Tutorials
MS Query Tutorial
Worst Pie Chart Ever?
The problem is there is a sequence of events. We must:
That's pretty much MySQL. I'm struggling how to do something like this in Access. I picked up an "essentials" book in access and it shows you the design view where you can specify criteria for particular fields, but it's not giving me an impression of a sequence of events where you do something and then something else.SELECT * FROM Table1 WHERE Table1.ColumnA LIKE '%Real Prop' && Table1.ColumnB LIKE '%DF' ORDER BY Table1.MI ASC;
Thanks for response.
I am not sure what you are alluding to here. Could you be more specific. If you are referring to running one query and then take action on that query and then take subsequent action on the second query, then you cannot do that all in one query. You will have to sequence your queries. This can be done in the QBE. Run your first query. Then create a second query which is based upon the first query and not on the original table(s). Do this until you get the expected results.but it's not giving me an impression of a sequence of events where you do something and then something else.
If I missed what you are looking for, post back with more information and perhaps with some sample data with expected results. That always helps to clear the matter.
Alan
Alan
Click the * below to say thanks.
Database Principles
Pivot Table Tips
Good Excel Video Tutorials
Sumifs or SumProduct
DataPig Access Tutorials
MS Query Tutorial
Worst Pie Chart Ever?
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks