Greetings,
I have a routine that iterates through many worksheets and Autofilters (using criteria filterStart and filterEnd) a range of data (A8:H200) using (field:=1). The code works well for that. What I want to do is filter using field:=1 unless field:=1 is empty, then I want to filter by another field. I have no idea how to accomplish this. - Sub ApplyDateFilter()
-
-
Dim Ws As Worksheet
-
Dim filterStart As Long, filterEnd As Long
-
Dim i As Integer, reply As Integer
-
filterStart = Range("B1").Value 'assume this is the start date
-
filterEnd = Range("B2").Value 'assume this is the end date
-
-
If filterStart = 0 Or filterEnd = 0 Then
-
reply = MsgBox("Please enter both filter dates!", vbOK, "Filter Dates")
-
Else
-
Application.ScreenUpdating = False
-
-
For i = 2 To Sheets.Count - 1 'ignores the first and last worksheet
-
Set Ws = Sheets(i)
-
Ws.AutoFilterMode = False 'Remove any existing filters
-
Ws.Range("A8:H200").AutoFilter field:=1, Criteria1:=">=" & filterStart, _
-
Operator:=xlAnd, Criteria2:="<=" & filterEnd
-
Ws.Activate
-
Ws.Range("I1").Select
-
Center_it 'Puts filtered totals in visible window
-
Next i
-
-
Sheet1.Select
-
Range("B1:B2").Interior.ColorIndex = 3
-
Application.ScreenUpdating = True
-
-
End If
-
End Sub
Thanks for any help.
2 6269
If you want to skip the empty line and process, it will be as follows. (By the way, named argument names can be omitted) -
Ws.Range("A8:H200").AutoFilter field:=1, Criteria1:=">=" & filterStart, _
-
Operator:=xlAnd, Criteria2:="<=" & filterEnd
-
-
Ws.Range( Ws.Range("A8"), Cells(Rows.Count, 8).End(xlUp)).AutoFilter 1,">=" & filterStart, _
-
xlAnd, "<=" & filterEnd
-
-
Create a new parameter:
data type string
allowable values set to list
add from field - user field
Quick filter on user-sending
select condition tab, By formula
[user.sending]=[user.parameter]
Repeat for user-receiving sheet.
Lastly, right-click user.parameter and select 'add to sheet' (or add it to you dashboard).
Sign in to post your reply or Sign up for a free account.
Similar topics
by: RichieTJ |
last post by:
-- Access Rookie Question--
Ok here is the situation:
I have a form called frmServices, that has three fields called SvcNo,
SvcName and SvcCity. I created a button that brings a popup form...
|
by: Randy |
last post by:
I have trying to figure out the above topic. Can someone help me with
this?
I need for staff to be able to go to a dialog box or a form and then be
able to enter data in mutliple fields and...
|
by: shaqattack1992-newsgroups |
last post by:
Hello Everyone,
At work, employees have been using a spreadsheet that I am trying to
import into an access database to make some reports. The problem I'm
having is that in the spreadsheet, they...
|
by: AtCor |
last post by:
I am trying to filter data using count. For a given day and patient, I would like to return all the valid tests. When I use a count this way, it only returns the patients with at least 4 tests. I...
|
by: nehashri |
last post by:
hi
i am designing a database using Ms Access and ASP. i have 3 tables in access namely 'PERSONAL', other as 'POLICY' and 3rd one is named as 'STAFF'. in the contact table i have ID, Name, Children...
|
by: ahd2008 |
last post by:
Hi everyone,
I have a form for departments and personnel. There are there fields for the sake of search:
DepartmentSearch as combo box
Division\UnitSearch as combo box
Number as combo box
...
|
by: tasawer |
last post by:
Hi,
I have an accident claims form that I need to requery on one of three different fields.
Primary field is AccidentID
ClientName (Can appear on more than one AccidentID)
SolicitorsRef...
|
by: Andre Saputra |
last post by:
Dear all.
I really need help for my code.
im using text box to filter data in listview, heres the code
reloadlistview1 "select * from sales where TANGGAL between #" & Text1.Text & "#" & _
...
|
by: mesairv |
last post by:
Hi everyone.
Im new here. I had been reading several topics in line with filtering, but i cannot find one related to my concern.
Please help me to create a command button that will filter my...
|
by: DesignsOnline |
last post by:
I have a table with many different fields in, including 40 separate image fields. ("Pic1" "Pic2" "Pic3" etc...)
each field has a single value (an image name) in, I need to be able to select all...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |