Excel Auto Attendance sheet - excel

im trying to make an automatic attendance sheet here are the details:
-Data will be imported in the excel sheet (left side)
-I want to automatically mark "p" or "a" a specific cell based on the data imported

since you're trying to check several conditions at the same time (date, time, id) in your source data I'd recommend normalizing the time to the start of the hour,
START OF HOUR FUNCTION
then adding a unique value for each you could concatenate "DATE", "TIME", "ID" with some type of separator for example "-"
CONCAT FUNCTION
and then you could try with using a lookup function to look for that specific value,
LOOKUP FUNCTION
with an IF function so that if the value is returned you print p or if false print a.
IF FUNCTION

Related

Filter function for multiple sheets

I am trying to filter data from multiple sheets using the newly introduced FILTER function. I have saved a named range for sheet names to use as an Array.
This is the formula I am trying to yse but it gives me #Value error. But it works if I use for a single sheet. aharu is the namedrange array for Sheet Names.
=FILTER(INDIRECT("'"&aharu&"'!$B$2:$B$1200"),(INDIRECT("'"&aharu&"'!$L$2:$L$1200")="")*(INDIRECT("'"&aharu&"'!$J$2:$J$1200")<=EDATE(TODAY(),-6)),"No data")
How to use filter function for multiple sheets?
To filter by using the FILTER function in Excel, follow these steps:
Type =FILTER( to begin your filter formula
Type the address for the range of cells that contains the data that you want to filter, such as B1:C50
Type a comma, and then type the condition for the filter, such as C3:C50>3 (To set a condition, first type the address of the "criteria column" such as B1:B, then type an operator symbol such as greater than (>), and then type the criteria, such as the number 3.
Type a closing parenthesis and then press enter on the keyboard. Your entire formula will look like this: =FILTER(B1:C50,C1:C50>3)
Here are the Excel Filters formulas:
Filter by a number
=FILTER(A3:B12, B3:B12>0.7)
Filter by a cell value
=FILTER(A3:B12, B3:B12<F1)
Filter by a text string
=FILTER(A3:B12, B3:B12="Late")
Filter where NOT equal to
=FILTER(A3:E1000, B3:B1000<>"Bob")
Filter by date
=FILTER(A3:C12,C3:C12<G1) (Date entered in cell G1)
=FILTER(A3:C12,C3:C12<DATE(2019,6,1))
Filter by multiple conditions
=FILTER(A3:C12,(B3:B12="Late")*(C3:C12="Active")) (AND logic)
=FILTER(A3:C12, (B3:B12="Late")+(C3:C12="Active")) (OR logic)
Filter from another sheet
=FILTER('Sheet Name'!A3:B12,'Sheet Name'!B3:B12="Full Time")
The Excel FILTER function:
=FILTER(A3:B12, B3:B12=F1)

SumIfs VBA function not working properly in macro

I have a form that is supposed to show the total sum of different numeric values between two dates, a start date and a finish date. For this, I thought the best option would be to use the SumIfs WorkSheetFunction. However, after trying to code this, the function is not working properly. I am not sure of what is wrong. If I type the exact same formula on the worksheet that has the table with my sample data, it works perfectly.
So, the form I designed is the following:
A second label and textbox will be added for the finish (or end) date. However, I thought it would be better to do that once I get the code to work with a single date in the beginning. The textbox where the user will insert the start date is called tbxDate and the textbox that will show the resulting sum is called tbxBalance. The button that triggers the SumIfs functions is called cmdCalculate.
Also, the table that stores the data (which only has one row of data so far for testing purposes) is this one:
The table name is Sales, and the worksheet name is SalesWS. I thought the code should be pretty simple, unless there is something I am missing. What I did was:
Private Sub cmdCalculate_Click()
Set SalesRange = Worksheets("SalesWS").Range("Sales[TOTAL]")
Set DatesRange = Worksheets("SalesWS").Range("Sales[DATE]")
tbxBalance = Application.WorksheetFunction.SumIfs(SalesRange , DatesRange , ">=" & tbxDate)
End Sub
The issue is that the >= part of the criteria is failing. I only get proper results using only the greater than or less than conditions. For example, if I enter the date 09/08/2020 in the textbox the result in the balance textbox is 0, but if I enter the date 08/08/2020 or anything before it works. It just ignores the condition to sum the values if the date is equal to what is entered. It only works with dates greater or less than what the user inputs in the textbox, excluding the chosen date.
I already checked that the column with the dates in the table is formatted properly.
The version of your code given below should work provided your DATE range contains true dates and tbxDate contains a string VBA can recognise as a date.
Private Sub cmdCalculate_Click()
Dim Fun As Double
Set SalesRange = Worksheets("SalesWS").Range("Sales[TOTAL]")
Set DatesRange = Worksheets("SalesWS").Range("Sales[DATE]")
Fun = Application.WorksheetFunction.SumIfs(SalesRange, DatesRange, ">=" & CLng(CDate(tbxDate.Value)))
tbxBalance = Format(Fun, "#,##0.00")
End Sub
Remember that tbxBalance will cotnain a text string, not a number. Use Excel's NUMBERVALUE function to convert the formatted number you have in tbxBalance after the above code back to a number you can calculate with.

How to set up Excel VBA Loop for vlookup

I have a dashboard (image below) where I manually add entries. Then there is a log (image below) where all entries are recorded with the help of IF and Vlookup functions.
I need a code so so that every output cell in the log finds through all the entries in the dashboard and gives the answer. I think loop for vlookup will be used.
[Edit]
Consider the Dasboard table as a discrete table where manually entries are posted.
Consider log table as a continues table where record of every hour for each date is kept. The entries from Dashboard table get posted to the log table. New Image attached New Image
I have entered this function in output column in the log table:
=IF( AND(H3=$B$3,I3>= $C$3,I3<$D$3) ,$E$3,0) + IF(AND(H3=$B$4,I3>=
$C$4,I3<$D$4) ,$E$4,0) + IF (AND(H3=$B$5,I3>= $C$5,I3<$D$5), $E$5,0)
This works fine for me for plotting the entries but the problem is for every row in the dashboard i have to add a new IF-And function in the above. so for example if i want to add the 4th row of dashboard to be sync with the log ill have to add
+If(AND(H3=$B$6,I3>=$C$6,I3<$D$6),$E$6,0)
I want every row in the dashboard to add automatically somehow with a loop like:
i = variable
= If (AND(H3=$B$i,I3>= $C$i,I3<$D$i), $E$i,0)
Only one i will be greater than 0 while the rest will be zero. so the function should return me the sum of all i rather than just the last iteration.
Maybe just filldown the formula manually? if insist with macro, something like
Sub test()
Range("K3").Value = "X"
Range("K3:K10").FillDown
End Sub
replace "X" with your formula, keep the " "
replace K10 with how far down you want
----edit----
let me break down below for you,
match(H3,B:B,0), will find the correct row in B that = H, in H3 case it finds B3
INDEX(B:E,MATCH(H3,B:B,0),2) -> now it find B3, index let you find C3 (notice the 2,3,4 in later codes, it means the column from B3)
and (I3>=...,J3>=...)now we got both start and end time, we use I and J to compare
if 3. is true, lookup the output column, else 0
=IF(AND(I3>=INDEX(B:E,MATCH(H3,B:B,0),2),J3>=INDEX(B:E,MATCH(H3,B:B,0),3)),INDEX(B:E,MATCH(H3,B:B,0),4),0)

Data validation based on LOOKUP

I've got two tables. Table A and Table B.
Table A has the following three columns: "Attribut ID", "Attribut Name" and "Value".
Example rows from table A(comma representing a new column):
"10000, Length, 3M"
"10000, Length, 5M"
"10000, Length, 7M"
"20000, Depth, 1,5M"
"20000, Depth, 3M"
"20000, Depth, 4,5M"
Table B has the following three columns: "Product Number", "Attribut ID" and "Value"
Example rows from table B(comma representing a new column):
"38-500351, 10000, 3M"
The sheet will be used by clients to input data, so I want to make everything as simple and as validated as possible, to minimize errors. Currently clients put in the "Value" in Table B (3M in the example) manually.
My goal is to change this to be based on a dropdown list, or at least be validated, based on Table A. So if 10000 is put in as the "Attribut ID" in table B, only "3M", "5M" and "7M" can be put in as values.
I've found this topic, which seems very similar, but I've been unable to figure out how to use it. Any help would be much appreciated. Avoiding VBA would be preferred if possible.
I've succesfully adapted Axcel's answer. Here's the modified code to adapt it to my sheet:
=INDEX('Attribut værdier'!$C:$C;MATCH(INDIRECT("RC[-2]";FALSE);'Attribut værdier'!$A:$A;0)):INDEX('Attribut værdier'!$C:$C;MATCH(INDIRECT("RC[-2]";FALSE);'Attribut værdier'!$A:$A;1))
I've changed "," to ";" and the sheet references. Other than that I've made no changes and everything works.
Assuming we have a situation like this:
Note that the Attribut ID in column A is sorted ascending.
Create a Name named "ValueList" using the Name Manager which refers to
=INDEX(Sheet1!$C:$C,MATCH(INDIRECT("RC[-1]",FALSE),Sheet1!$A:$A,0)):INDEX(Sheet1!$C:$C,MATCH(INDIRECT("RC[-1]",FALSE),Sheet1!$A:$A,1))
How to use Name manager, see https://support.office.com/en-us/article/Define-and-use-names-in-formulas-4d0f13ac-53b7-422e-afd2-abd7ff379c64?ui=en-US&rs=en-US&ad=US#bmmanage_names_by_using_the_name_manage
The "RC[-1]" within the INDIRECT must be changed accordingly the language version of your Excel. For German Excel it has to be "ZS(-1)".
This named range will dynamically get the range in column C from the first occurance of the "Attribut ID" till the last occurance of this "Attribut ID" in column A. The "Attribut ID" is taken from the cell left of the cell it is assigned to.
Then you can use this named range as source for the list within Data Validation (Source =ValueList) for the dropdowns in column G.

Suppressing pivot items in a pivot chart

I have created a pivot table that lists the number of visitors to a store on a given date. There are 3 columns of data, the date column and two columns of numbers representing the visitors. When I create a chart from this data I get a bar of data that represents dates before and after the range of dates that make up the data. I can suppress all dates that occur prior to the dates I want to view by using the command:
With Worksheets("Pivot Tables").PivotTables("Weekly Statistics").PivotFields("Date")
.PivotItems.Item(1).Visible = False
However, I can't find a way to suppress the dates that occur after today's date. This leaves me with a column on my bar chart that is blank and has the axis value ">3/27/2013". I can suppress it by actually typing this line:
.PivotItems.Item(">3/27/2013").Visible = False
but having to manually do this every time I update the sheet is laborious and makes the sheet unusable to anyone else.
I tried to create a variable that would update the value inside the () but I can't get it to work.
Dim t
t = Worksheets("Data").Range("i3").Value
.PivotItems.Item(t).Visible = False
(where i3 is a cell in the Worksheet("Data") that is a concatenation of the date; in this case the cell contents are ">3/27/2013" )
Thanks
You could try to use alternative filtering technique:
t="3/27/2013"
Worksheets("Pivot Tables").PivotTables("Weekly Statistics").PivotFields("Date").PivotFilters.Add Type:=xlBefore, Value1:=t
However, it is used as of Excel 2007.
If not working try to start with:
Worksheets("Pivot Tables").PivotTables("Weekly Statistics").PivotFields("Date").ClearAllFilters

Resources