Please help with VB in calculation

CThai

Active Member
Joined
Mar 18, 2007
Messages
295
Hi
I'm looking for some help in calculating the week, month and year average,

In column A i have the dates (01-Apr-99 thru 01-Jan-06)
column B = Unit ID
column C = Owner name
column D = Plant ID plant ID would be use as a Key ID, since plant ID is different
column E = Plant Name
column F = Capacity offline (this is what i need to use to calculate)
column G = Type
column H = Unit type
column I = week
column J = month
column K = Year

I would like to create a pivot table where i can select a Plant ID and it would show me the average of the week, month and year... and all the other information...

is there a way to create this?

Thank you

Cthai
 
I did it manually to calculate the weekly average ---

I hope this explain what I am looking for:

what i need is

anything in "week" 14/1999 to sum and get the average for "Capacity offline" for the weekly average...
Please let me know if this is something you can help me with or if you need more information..

thanks a bunch!


EDIT: I deleted your HTMLMaker shot as it was too big and blowing the page out of proportion - Can you try a smaller sample? Smitty
 
Upvote 0

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Your problem with the columns is that 52 weeks * 6 years exceeds the 256 column limit. Try filtering by year: place Year in the Page Field area, select one of the years, then refresh the PT. You should then see all weeks for that particular year.

Denis
 
Upvote 0
sorry about the image -

here is a smaller one -
PADD1_test.xls
ABCDEFGHIJKLM
1Outage DateUnit IDOwner NamePlantIDPlant NameCapacity OfflineWeekMonthYearWeek ReferDAILY AVERAGEWEEKLY AVERAGE
219-Mar-011001619Sunno1863502Eagle15000012/200131-Mar-01200112150000150000
320-Mar-011001619Sunno1863502Eagle15000012/200131-Mar-01200112150000
421-Mar-011001619Sunno1863502Eagle15000012/200131-Mar-01200112150000
522-Mar-011001619Sunno1863502Eagle15000012/200131-Mar-01200112150000
623-Mar-011001619Sunno1863502Eagle15000012/200131-Mar-01200112150000
724-Mar-011001619Sunno1863502Eagle15000012/200131-Mar-01200112150000
825-Mar-011001619Sunno1863502Eagle15000012/200131-Mar-01200112150000
926-Mar-011001619Sunno1863502Eagle15000013/200131-Mar-01200113150000150000
1027-Mar-011001619Sunno1863502Eagle15000013/200131-Mar-01200113150000
1128-Mar-011001619Sunno1863502Eagle15000013/200131-Mar-01200113150000
1229-Mar-011001619Sunno1863502Eagle15000013/200131-Mar-01200113150000
1330-Mar-011001619Sunno1863502Eagle15000013/200131-Mar-01200113150000
1431-Mar-011001619Ohio1008348Point15000013/200131-Mar-01200113150000
151-Apr-011001619Ohio1008348Point15000013/200130-Apr-01200113150000
162-Apr-011001619Ohio1008348Point15000014/200130-Apr-01200114150000150000
173-Apr-011001619Ohio1008348Point15000014/200130-Apr-01200114150000
184-Apr-011001619Ohio1008348Point15000014/200130-Apr-01200114150000
195-Apr-011001619Ohio1008348Point15000014/200130-Apr-01200114150000
206-Apr-011001619Ohio1008348Point15000014/200130-Apr-01200114150000
217-Apr-011001619Ohio1008348Point15000014/200130-Apr-01200114150000
PADD1_weekly
 
Upvote 0
Hi SydneyGeek -

I added the year and it's not showing the weekly average - for each year. i manually input the weekly average and monthly average so that when i put it into the pivot table i will show....
 
Upvote 0
I'm having trouble visualising your layout. Send me a PM, I'll reply with my email address, and you can send the file.

Denis
 
Upvote 0
A PivotTable is about as efficient as one can get in terms of worksheet space usage. If it doesn't fit then no solution you come up with will fit on a worksheet.

That said, are you sure you had the row and column fields as I indicated and not the other way around?

Hi tusharm

I try to follow your idea for the pivot table but when i click finish to run the table i get an error " the Pivot talbe will not fit on the sheet"...

The idea is - i want to be able to select the Unit type (i.e CCR) see the capacity offline, averge (week, monthly and year) as well as the owner name, type... etc...

I dont know if pivot table is the best way too go, since i have a huge data... i would take any suggestion... just need something that works :)

thank you

Cthai
 
Upvote 0
hi tusharm

In a PivotTable, put the PlantID as the row field, the week, month, and year as column fields and the Capacity Offline as the data field. For the data field, change Excel's default choice of Sum to Average.

that is exactly how i have the table created...

is there a way i can use VB to generate the daily/weekly/monthly average? and show only some of the information that needed...
 
Upvote 0
If the number of Plants is "reasonable," put the PlantID as the column field and the others as row fields.

Alternatively, create one PT for each of the Month, Year, and Quarter.

And, as far as relying on VBA goes, I really don't understand how it would yield better results. If there isn't enough space to show the results there isn't enough space to show the results. I'm sorry, but VBA is not going to create additional columns out of thin air! And, if you are willing to see less amount of information through the use of VBA why not do the same with Excel-native tools?

hi tusharm

In a PivotTable, put the PlantID as the row field, the week, month, and year as column fields and the Capacity Offline as the data field. For the data field, change Excel's default choice of Sum to Average.

that is exactly how i have the table created...

is there a way i can use VB to generate the daily/weekly/monthly average? and show only some of the information that needed...
 
Upvote 0
If the number of Plants is "reasonable," put the PlantID as the column field and the others as row fields.

Alternatively, create one PT for each of the Month, Year, and Quarter.


the report have about 7000+ entries ... here an example of the pivot table
pivot.xls
ABCDE
3Unit ID(All)
4Capacity Offline(All)
5Outage Date(All)
6
7PlantIDDataOwnerPlant NameTotal
81028348Sum of DAILY AVERAGEBmoreFEN220000
9Bmore Total220000
10Sum of WEEKLY AVERAGEBmoreFEN31428.57143
11Bmore Total31428.57143
12Count of MONTHLY AVERAGEBmoreFEN
13Bmore Total
141028348 Sum of DAILY AVERAGE220000
151028348 Sum of WEEKLY AVERAGE31428.57143
161028348 Count of MONTHLY AVERAGE
Pivot
 
Upvote 0
tusharm,

i'm going to create a different sheet for weekly/monthly average - and see if the errors still occurs... i know that pivot table should be able to give me what i'm looking for... i just need to get it right...
 
Upvote 0

Forum statistics

Threads
1,216,583
Messages
6,131,557
Members
449,655
Latest member
Anil K Sonawane

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top