PDA

View Full Version : Macro itp



thorgrim29
2010-05-04, 03:18 PM
Hi, I need a Excel macro for work and I only have a very well, basic understanding of basic. Basically, I need to sort which employees do admin work in different projects and which do not, only they don't all work on every projects. I have the info by project, arranged like this:

Project 1:
Employee:fillerwhitetext A E G M ......
Total hours for projectb x y z aa


Total hours_admin: ??
Total hours_engineering: ??

Say employees A, J and K do admin work, and the rest are engineers, I need a way to automatically get the total hours, probably a long if, then chain, but my basic is so weak I can't pull it off, and the resident programmer is off for the week, so I ask for the help of the playground.

Also I'm going to need a way to translate that into dollars, and each employee is payed differently, but that's more mid term compared to the other issue.

p.s. First time I officially get payed to be on giantitp, lol.

Any ideas?

Pyrian
2010-05-04, 03:58 PM
In Excel you're generally better off splitting the work into multiple cells rather than overloading it into one cell. So far, what you've described is not very complicated.

Here's a very simple strategy with no programming:

Add five rows under the employees - don't worry about the space, you'll hide them later. For the first row, place a "1" for each admin employee and a "0" for each engineer, and on the next row reverse that. On the fifth row, get a sum for that employee (i.e., all project rows below). "=sum(C8:C65536)" or some such. Copy that under each employee. Then, on the third inserted row, multiply the sum times the admin column, and on the fourth inserted row, multiple the sum times the engineer column. (Note that while building a formula - anything after an "=" sign - you can just click on the cell you want to refer to.)

Finally, the sum of the third and fourth rows are the totals for each category. No if-then's required!

thorgrim29
2010-05-04, 09:33 PM
I thought about that, but it would actually be shorter to just do it manually since I'd have to do it again each time I need that report, that's why I wanted to automatize it, right now I have time on my hands but that'll change soon enough