Excel VBA to select new data and transfer to the next blank line in another worksheet - vba

I have found a couple places that this has been touched on but I am not a programmer by any means so I am having difficulty using what I have found. I have been teaching myself VBA for access but I am very lost as to how to go about this in excel.
I have two work sheets in my workbook. One is called "Field" the other is called "DTE" in the Field sheet I have employees tracking the number of ballasts that are installed at a certain job site. The DTE is more indepth and is the sheet that our customer needs. Our guys are not at all tech savvy so I need to find the easiest way (one button click type of situation) to have the information transferred from "Field" to "DTE".
Here is some information on the data:
Field contains three tables (they are currently left to right but I can make them top to bottom if that is messing the codes up)
The first table is for ballasts, second for fixtures. There third is not necessary for this question.
There are multiple types of ballasts and fixtures which is where the difficulty comes in.
For example:
I need to have certain information transferred over, on the field form the guys type the location as well as how many of each type of ballast/fixture. In the DTE I need this information to be arranged slightly differently.
If the Row in the field form looks like this:
Location Ballasts 1 Ballasts 2 The second looks like this:
Hall 3 4
and then I need the DTE to look like this
Location Quantity Type
Hall 3 Ballasts 1
Hall 4 Ballasts 2
I know this is extremely in depth and I apologize in advanced because this is much more difficult than I wanted to make it but if anyone could help I would really appreciate it. Thank you so much!
(Also if you think another answer may help please link me to it, I have tried to use many of them and alter them to fix my tables but I just come up with a ton of errors. Thank you again!)

Related

Displaying rows based on column label in Excel for a Pivot Table

I'm facing the following problem. I have a very large excel sheet in the format attached as a picture. For reasons beyond my control the basic formatting of this sheet needs to be maintained as people with no skill want to be able to edit this.
However, I need to work with the content and as it is quite large, it is really unreadable. So what I wanted to do is to be able to find the tasks belonging to different departments and the different people. My approach was to create two pivot tables where I want a dropdown list with either the department or the person to be able to filter on the tasks that that belong to each of them. I have found how to filter on a dropdown menu, however this is for column entries. What I want to do is to filter on the column labels and then display the tasks for which the column I selected is non empty.
I need some help on the direction in which I need to search for the answer to this problem as I'm currently lost in solutions that have nothing to do with this problem.
Thanks in advance
You can use Power Query Excel 2010+ you can download and activate easily or by default in 2016 version. There you can keep this format for your users and a pivot table for control.

Excel: Increasing/Decreasing number of columns in table based on number of coloured rows from different sheet

I am in the process of creating a costing summary workbook. My main summary sheet lists a job category and then 4 rows of cost breakdown before the next category is listed. On another sheet, I have a template that the user will make a copy of for each month, which breaks down weekly work hours and then allocates hours from each employee/plant to against a job category. Please see attached pictures.
Summary Sheet -
Template Sheet
My goal is to have the number of columns on the template increase/decrease as categories are added to or removed from the summary sheet. I already have a cell that contains a count of coloured rows (category titles), and i figure i should be able to use this to determine the amount of rows that need to be added to or removed from a table. I can't think of any ways for this to be done without macros or VBA code of some kind, which I am open to but I would like to minimise the use of.
Can anyone provide me with some code or a push in the right direction for this kind of function? Category names will be stored in column A, or my count is stored in B84. Columns for each category start from column S in the template sheet.
Kyle, you can visit the following sites with a lot of vba beginners information.
http://www.excel-easy.com/vba.html
http://www.homeandlearn.org/
https://www.tutorialspoint.com/vba/
Try implementing your idea using pseudo-code.
http://www.vikingcodeschool.com/software-engineering-basics/what-is-pseudo-coding
https://www.youtube.com/watch?v=4G0EYfrrDT8
https://www.khanacademy.org/computing/computer-programming/programming/good-practices/p/planning-with-pseudo-code
Once you be able to write your code and you are having some code error or problem you cannot find a solution in the web, come again and ask specific questions, there are a lot of experienced programmers that will be happy to help you to solve your coding problems.

Filtering to new sheets from master sheet in Excel

Im wondering if this is possible with excel. I have a list of employees with multiple columns counting up their production in my company. It is a list of about 40 names and has about 10 columns of different tasks that are counted up to determine productivity. these people are split up into different teams and i have their names tagged with the team. For example, if joe smith was in customer service, his name says CSR-Joe Smith. I want to be able to use this excel sheet over and over again so i can simply run this master report and put the data into one sheet to populate a different sheet for each team. Is there a way to do this by looking at the team tag i add to each persons name and extract from the list of employees the team members that are on the same team? Im working on excel 2010 and have some knowledge of VB and C coding in excel but not a ton of experience with it. I also want to pull the values for each team member in each column.
here is an example if my words didnt make sense, each employee has a row like this.
name status1 status 2 status 3 status 4 status 5
CSR-Joe Smith 251 358 12 58 9
I should mention that this data is gathered from a SQL query that i want to pull out of MS SQL management studio and am copying into excel.
To sum it up, my solution for this kind of problem and related:
Solve database-problems in a database, whenever you can ;)
It is far more easy to make joins, selection and filtering inside a database, than inside excel.
If you have to do it in excel, see if subsum, pivotTable or vlookup can help you, because those could most likely do.
Be alarmed, when you start trying to solve database-problems with vba - usually there are better ways, or at least there should be. When you have a good datasource - like sql - it should definetly be your first attempt to get create a better view or table in sql.
Additionlly, you can use .odc connection-files with excel directly. By opening one, you create a new Workbook and you will open your connection as a worksheet.

Comparing two columns and matching values from seperate work sheets

The goal of my project is to create an out of office program that will allow easy tracking and auditing of our Sharepoint site as it doesnt have a built in system to do. I have no background in VBA, but I have done quite a bit of python. That being said I've ran into my first issue. I'm not sure how the syntax works, and what commands I should be using to get the results I want. I.e. sheets vs worksheet vs worksheets.
I have a workbook, 1 sheet is Raw Data, in which I import data from a sharpoint site. It displays the following columns
Resource Name -- Absence Type -- ID -- Start Time -- End Time -- Created -- Modified by
The next sheet I have is tracking, it's called Tracking. On this page the user imputs Resource Names they want to track into Column A, and then the remainign columns are going to display the number of absences that name has so it will look something like
Resource Name -- Vacation -- Sick -- WFH
Clooney, George -- 2 -- 0 -- 7
A counter will run based on each instance that appears in raw data and adds the number to the counter based on the absence type from raw data.
I need a way to loop through Raw Data and look for the names that appear in the Tracking data. If Possible I'd like to store them in a third worksheet jsut for testing purposes. I know the logic I need to use, but what I dont know is the syntax to refrence the pages together. Any insight on the best way to accomplish this?
Question : I need to Search raw data for every instance Resource Name appears in it from the Tracking page and store into another worksheet.
If you don't want to use PivotTables (can be hard to search later) this is the way to do it with COUNTIFS. This formula goes in the "Sick" column of Tracking in row 2 (assuming row 1 is headers).
=COUNTIFS('Raw Data'!A:A,Tracking!A2,'Raw Data'!B:B,"Sick")
It assumes that in Raw Data Name is in column A and AbsenceType is in Column B, but it doesn't matter how many records there are.
The way I understand your question (and it wasn't easy), you are dealing with a bunch of timesheet info. You seem to be trying to count the number of instances of different kinds of time off that people are taking - whether that be vacation, sick or working from home(WFH).
I've never heard someone's name referred to as a "Resource Name" lol.
You really don't need to use VBA for this problem - at least not anything that you can't just record a macro for - it seems to be a rather simple problem that can you solve using a pivot table.
If you want to you can set up a vlookup reference to this pivot table to create the little form that you seem to be trying to create. But really I think your better off just teaching whoever is going to be using this about pivot tables. Let me know if I misunderstood your question and I'll be happy to delete this post.

Determining whether VBA is necessary in Excel, or if a pivot chart/table can suffice

I wish that I had a more precisely descriptive title for this question, but I am not very knowledgeable with Excel spreadsheets or VBA (I'm primarily a Java developer, and don't play much in the Microsoft world).
I'm trying to use an Excel spreadsheet to accomplish something. I need to determine whether I can get there with a PivotTable, PivotChart, or some other built-in functionality... or whether I need to go down the path of writing custom VBA code (or maybe using another platform altogether).
The purpose of the spreadsheet is to help create schedules for an organization (a Toastmasters club). This organization has a roster of members, it meets weekly, and various members are assigned to various roles in a given meeting.
My spreadsheet looks like this:
First Tab
One column... a list of names representing the membership roster.
Second Tab
Each row represents a past meeting date. There are columns for each role, and the cells are to be populated with who served that role on that date. I use Data Validation to have the first tab's roster available inside each cell as a pulldown.
Third Tab (maybe multiple tabs?)
Here's the point of the whole thing. For each of the possible meeting roles, I would like to see which members are the most "overdue" to be assigned for that role. Basically, I want a list of all the club members, sorted in order of how long it's been since they last served that role. People who have never served in that role would be sorted at the top of the list.
Is that third tab data something that can be accomplished with a PivotTable, etc... or am I misunderstanding the purposes and limitations of those tools?
I found a way you can do this with pivot tableS - one per role. It's a bit dubious whether you should, but depends how many roles you have really. I made it work using 2 as a sample, here's the gist:
You have an (Excel) table containing Names
You have an (Excel) table containing Meeting Date, RoleA, RoleB... (I used Chair and Secretary as nominal examples), these cells contain the name of the person taking that role
You then create a Pivot Table for each role (Insert --> Pivot Table). The fields to use are: Row Labels - whichever role you're analysing; Values - Meeting Date
You then change the result type by going into Field Settings, and change it to Minimum. Note that only people who have had that role will show up here.
Repeat this for each role.
Go back to your table of names, and add a column for each role to show when they last held the role. The formula for this is the rather unwieldy:
=IFERROR(GETPIVOTDATA("Meeting Date",Chair!$A$3,"Chair",People[[#This Row],[Name]]),0)
The GETPIVOTDATA will error if they haven't had that role, so I'm replacing errors with 0 (an arbitrary low number)
You can then identify the person most overdue for the role using:
=OFFSET(People[[#Headers],[Name]],MATCH(MIN(People[LastChair]),People[LastChair],0),0)
If there is a tie, the person who appears first in your list of names will be given here.
Hope that makes some semblance of sense, ask away if any questions
My first instinct is to move you to Access where you can SQL query to your heart's content, but I'm sure this can be done in Access without any custom coding.
PivotTables may work, but I avoid them for several reasons (hard to describe to casual users, doesn't update automatically, hard to format, etc.), so here is something using just Excel's built-in cell functions.
Check out vlookup() and countif() on http://www.techonthenet.com/excel/formulas/index.php. (The built-in help files work too. I just like this site more)
In the image below, I have simulated your Tab2 and Tab3. Tab2 is purely data with no equations. Vlookup() requires that this table be sorted by Date Descending and with the date column on the far right.
Tab3 counts both the # times each person has served in that role and when they last worked that position.
The formula in cell C13 is =COUNTIF($B3:$B8,$B13). i.e. it counts the number of times that "Abe" appears in the Chairperson column of Tab2.
The formula in cell D13 is =IF(C13>0,VLOOKUP($B13,$B$2:$D$8,3,FALSE),"-"). i.e. if that person ever served in that role, then it finds the most recent date.
The formulas for security are almost the same. The "Last Served" column is now =IF(E13>0,VLOOKUP($B13,$C$2:$D$8,2,FALSE),"-"). The ranges need to be renamed here to satisfy the needs of the Vlookup function (a SQL query would be really convenient here, but Excel doesn't allow that)
It's hard to define if someone is 'overdue' because some people will argue that "Last Served" is more important than the "# Times Served" and others will argue the exact opposite. I suggest looking at both columns and just talking it over.