VLookup multiple values - vba

I have a table of Dates and Days in a specific time range called Data
I also have a sheet of a specific employee called "Jackson" and a sheet for employees to input their free time in so I can generate Jackson sheet.
I tried VLookup so if Jackson input Monday" as his free time, the Jackson sheet will print out a template of all Mondays in the given time range. I want it also to print out the dates based on the table of date/days.
Here is a picture of what I would like:
Stack Overflow has saved me SO MANY MANY MANY times, thank you for your helps!

You could use "&" between the two lookup criterion and table arrays. Be sure to make the formula an array with ctrl shift enter

Related

Search entire workbook with two criteria

Gooday, Pls I'm partially new to vba. I have several spreadsheet in a workbook for a work station that is prone to making shortage or surplus in daily delivery as a result of human errors. I want a scenario where I can search the entire workbook to extract data from Column K(which displays shortage or surplus) , but it must meet a certain criteria in Column A(date of delivery) and Column D(location of delivery). In other words, I would like to search Column K to know if there is shortage or surplus for any day I choose to search based on date. Any form of assistance is highly appreciated. Thanks.
Your solution could include an InputBox and the Range.Find Method, where you search column A for date, read in the row, and look at column K of the same row. In fact, the Range.Find example is pretty easily modified for your needs.
But you mention location in Column D, so what constraints are on column D? You'll also need to be more specific about where/how you want to extract the data from column K.

I am trying to write a vba code to extract Data from a workbook based a given date range. User should be able to enter date range

I am trying to write a simple vba code to extract data from the work hour sheet. User should be able to specify a date range and the vba code should able to extract the data based on the range.
The hour sheet has dates mentioned in the columns and work items in the rows. Users put their hour spend for the day against the given work item in the corresponding dates.
For ex. if I select range 01-08-2015 to 01-08-2015 the code should be able to extract the hour spend in the given date range for the particular work item. The data should then be shown to the user in the Calculations sheet.
I was looking to add a command button to facilitate the process
Work Items are arranged in rows and dates are arranged in columns.
Without seeing the spreadsheet, my gut would say to try something like this. Create a new sheet that has a spot for the starting date and ending date to be put in cells, eg A2 = starting date and B2 = ending date. If this is for a user, have the label for this in A1 and B1. Add a command button that will run the macro. macro should use a loop to find all the dates within the range, it would be easiest if the master data sheet was sorted, then have the code copy and paste the cells as needed. Without more details on the sheet layout, I can't really put some code together for you.

#REF! result when using INDEX function in Excel

I am trying to create a couple of reports from data on another Excel worksheet based on the value in a drop down list. I am using the MATCH and INDEX functions and have created Named Ranges of the columns of data. I am able to get the first value I want in the report but none of the others, even though when I debug by evaluating the formula it points to the right cell but still displays #REF! instead of the actual value from the referenced cell.
I'll do my best to make this clear:
In "POST_Data" worksheet I have 4 columns titled Course Name, Course Length, Attendee and Date Attended. Currently I have 33 rows of data (plus the header row) but I need the reports to be dynamic since new data will be added from time to time.
I have created Dynamic Named Ranges of the data using the OFFSET function (e.g. for the Course Name data I have a NameRange called CourseNamesData = OFFSET(POST_Data!$A$2,0,0,COUNTA(POST_Data!$A:$A),1)
In the "DashBoard_and_Data Entry" worksheet I have a two report areas: one to report the Course Name and Date Attended for a specified Attendee (specified by a drop down list in cell C7) and the other report to provide the Attendee Name and Date Attended for a specified Course Name (specified by a drop down list in I7).
In row 8 I report the column that the data belongs to in the POST_Data worksheet
What IS working: When I choose an Attendee from the drop down list in C7, I correctly report the first of the Course Names for this attendee from the data in the POST_Data worksheet. I used the following formula to do so: =INDEX(CourseNamesData,MATCH(C7,AttendeeNamesData,0),B$8)
What is NOT working: The corresponding "Date Attended" data when I use a similar formula as the one that is working. I have: =INDEX(DateAttendedData,MATCH(C7,AttendeeNamesData,0),C$8) but this gives me the #REF! error.
Again, when I try to follow the data that this formula points to, it looks like it is pointing to the correct cell but not showing the result.
Another issue is how to get all the data corresponding to the choice in the drop down and not just the first row. So for example, if I choose Richards, K. from the attendee list and he has attended 4 training courses, I need all 4 to show up, not just the first one.
I appreciate any help or insights on this. If you know of a better way to display the workbook contents, please let me know.
Thanks!
Can you provide a screenshot so that I can better understand the issue?
With regard to your post_data worksheet, you might find it easier to turn the data into a table. You can then point your named range to the column within the table without needing to use the offset function, and your range will update automatically as you add to the table.
I have a entire playlist on my youtube channel devoted to using ranges and tables if you are interested. https://www.youtube.com/playlist?list=PL1nLTDk2QLL9415OPSjIICJs1EeV-HeK3

Autofill Custom List

I am trying to code a schedule generator in Excel using formulas or VBA that can automatically fill in the correct cells with data from a custom list (it can be stored anywhere - another spreadsheet, somewhere in the same sheet). Does anyone know an easy way to do this using VBA/Excel formulas or some other method (maybe even a better program to do it in)?
A user should type the start date in a cell and then it automatically fills in the same data into the weekdays, skipping weekends and holidays, which are also user inputted somewhere in a spreadsheet.
This picture explains what I am trying to accomplish:
There would be a place to input a new class and start date and the rest would auto fill. The custom list would be the titles (i.e. Database Basics, Tables, Primary Keys, Foreign Keys and so on)
The top two rows are date and day of week (that part is easy) but then give a start date fill in the list (until you reach the end of the list) in the weekdays but do not fill in weekends or user chosen holidays. Ideally this would work for every row. So if I have multiple start dates then maybe rows 3,4,5 would have different schedules but I can see where they coincide and do not based on this simple view.
This is a description of a technique that you may adapt for your use. Say we want to auto-fill dates (working days) in row #1 based on a staring date in cell A1.
Leave A1 empty. Format the cells in row #1 as Date.
In B1 enter:
=IF(A1="","",WORKDAY(A1,1))
and copy across. Now when a date is entered in A1, the rest of row #1 will follow suit.

CountIfs date range AND conditional, possibly a VBA solution

Okay, so here is a sample my current code. I have this in several cells , where B-H7 reflect the absence type it is searching for.
=COUNTIFS('Old Data'!$A:$A,Tracking!A8,'Old Data'!$B:$B,$E$7, 'Old Data'!D:D, ">"&$B$5, 'Old Data'!D:D, "<"&$C$5)
What this code is doing is looping through a spreadsheet, where the employee name is found in the data sheet, comparing the absence types and assorting them to their respective columns and counting them, the last bit of code restricts the search between date ranges.
That being said, I need to add conditions to this that I'm not sure I can without taking it into VBA. In the "Old Data" Sheet in column D I have start time, which displays in MM/DD/YY HH:MM format. In Column E I have End Time, which displays in the same MM/DD/YY HH:MM format.
I need to have a way to
A.) Have the progam count the number of days between these dates and a +1 to the count for each respective day.
B.) If the start and end date are the same, have the program compare the number hours. if it is less than 4, only add a .5 to the counter.
My first thought is to scratch the countifs formula and loop through and parse it out using VBA, but I thought I'd check first to see if it can be done with just the formula as the power of the built in function has been pretty surprising to me so far.
I think I should probably take this from a formula to a VBA function and call it in the cells, but I'm not entirely sure, pretty new to the VBA/Excel scene.
Also, I'm in Excel 2007.
Thanks for any input on this issue!
It's possible to do with a formula but not with COUNTIFS. This array formula should do it
=SUM(IF(('Old Data'!$A$2:$A$100=Tracking!A8)*('Old Data'!$B$2:$B$100=$E$7)*('Old Data'!$D$2:$D$100>$B$5)*('Old Data'!$D$2:$D$100<$C$5),IF('Old Data'!$E$2:$E$100-'Old Data'!$D$2:$D$100<"4:00"+0,0.5,INT('Old Data'!$E$2:$E$100)-INT('Old Data'!$D$2:$D$100)+1)))
confirmed with CTRL+SHIFT+ENTER
I restricted the data range to rows 2 to 100, adjust as required, whole columns is possible but that may slow down the formula considerably
To count workdays only change to this version:
=SUM(IF(('Old Data'!$A$2:$A$100=Tracking!A8)*('Old Data'!$B$2:$B$100=$E$7)*('Old Data'!$D$2:$D$100>$B$5)*('Old Data'!$D$2:$D$100<$C$5),IF('Old Data'!$E$2:$E$100-'Old Data'!$D$2:$D$100<"4:00"+0,0.5,NETWORKDAYS('Old Data'!$D$2:$D$100+0,'Old Data'!$E$2:$E$100+0))))
You can also exclude holidays if you add a holiday range to the NETWORKDAYS function