Hi Guys,
I have another request for help. I've been plugging away at my tool. (over 12,000 lines of code now). And I'm struggling with this next bit. The tool will generate a final report (I've attached a sample skeleton) and automatically creates the tabs, names them and formats them. It'll export the data into the "xxx Data" tabs. And I have been able to get it to automatically create the correct number of employees per site automatically.
Here's the hard part. You'll have to reference the "Prescott" or "PCT" tabs in the file to understand what I'm trying to do. (I had to strip it down so that it would upload, the file was over 3MB.)
Anyway, COLUMN A of the "PCT Detail" tab has a series of codes. If you look at COLUMN J of "DCT DATA" you will note that those codes correspond. I need a macro to automatically count the number of times each code is used and paste it in the appropriate column (So, For "Employee 1" it'll count them on the PCT Data sheet and then paste the number of times that code was used into Column B of the PCT Detail sheet. Employee 2 would have their results posted into Column D, etc.) Here's the catch, I need this macro do this dynamically. Not all sites have the same number of employees. I dont always know who's going to be listed in Row 2 at any given site, so I need the macro to figure it out all by itself. Frankly, I'm stymied. Any help would be appreciated.
Thanks!
Last edited by JohnathanC; 03-18-2010 at 01:11 PM.
Hi
You can get the result you want by using the formula
=SUMPRODUCT(--('PCT Data'!$J$2:$J$431='PCT Detail'!$A9),--('PCT Data'!$C$2:$C$431='PCT Detail'!B$2))
in PCT Detail!B9, and copying down/across as required.
The ranges will be variable, so if you create a variable that will give you the last row used in PCT Data, then you can build the formula. Once you have it created, the macro can be used to copy down / across based on the number of columns used.
HTH
rylo
Hi Rylo,
thanks for your reply! The formula you used above works exactly like I need it to, but I cant seem to figure out how to get it to work as a macro. I know that I can't just useBut I'm not sure how to work it. Do you have any ideas? Thanks again!Code:"Range("B53").FormulaR1C1 = "=SUMPRODUCT(--('PCT Data'!$J$2:$J$431='PCT Detail'!$A52),--('PCT Data'!$C$2:$C$431='PCT Detail'!B$2))"
Nevermind.I figured it out;
Thanks!Code:Range("B53").Formula = "=SUMPRODUCT(--('PCT Data'!$J$2:$J$431='PCT Detail'!$A52),--('PCT Data'!$C$2:$C$431='PCT Detail'!B$2))"
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks