Data to be processed using VB Macro

Nitya0808

New Member
Joined
Jul 1, 2016
Messages
42
Hello All,

There is a set of data in sheet 1.

CategoryUnitPeriodDataLifecycle

<tbody>
</tbody>


There are 5 different units, and the categories can be similar or different across data. The data needs to categorized across units, per category, per period based on the lifecycle (only Active lifecycle is taken into calculation) in sheet 2.


Sheet 1


Cell Formulas
RangeFormula
A1Category
A2A
A3A
A4A
A5B
A6B
A7B
A8C
A9D
A10A
A11A
A12C
A13C
A14C
A15D
A16D
A17D
A18A
A19B
A20C
B1Unit
B2X
B3X
B4Y
B5Z
B6Z
B7Z
B8X
B9Y
B10X
B11Y
B12Z
B13Z
B14Z
B15W
B16W
B17W
B18X
B19Y
B20Y
C1Period
C2P01
C3P01
C4P02
C5P02
C6P01
C7P01
C8P02
C9P01
C10P02
C11P01
C12P02
C13P02
C14P01
C15P01
C16P02
C17P02
C18P01
C19P01
C20P02
D1Data
D2345
D3678
D432
D5567
D666
D7-90
D8100
D911223
D10865
D11124
D12674
D13742
D14983
D15345
D16742
D17641
D18578
D19444
D20980
E1Lifecycle
E2Active
E3Active
E4Mature
E5Active
E6Active
E7Active
E8Active
E9Active
E10Active
E11Mature
E12Active
E13Active
E14Active
E15Active
E16Active
E17Active
E18Not Applicable
E19Active
E20Active


Sheet 2


Book1
BCDEFGHIJKLMNOP
4UnitCategoryP01P02P03P04P05P06P07P08P09P10P11P12Total
5XA1,023.001,023.00
6C865.00100.00965.00
7Total1,888.00100.001,988.00
8
9
10WD345.001,383.001,728.00
11Total345.001,383.000.000.000.000.000.000.000.000.000.000.001,728.00
12
13
14YD11223.0011,223.00
15B444.0032.00476.00
16C980.00980.00
17Total11,667.001,012.0012,679.00
18
19
20ZB-24.00567.00543.00
21C983.001,416.002,399.00
22Total959.001,983.002,942.00
23
24
25OverallA1023.00865.001,888.00
26D11568.001383.0012,951.00
27B420.00567.00987.00
28C983.002496.003,479.00
29Total12,971.004,446.0019,305.00
Sheet2
Cell Formulas
RangeFormula
D7=SUM(D5:D6)
D11=D10
D17=SUM(D14:D16)
D22=SUM(D20:D21)
D29=SUM(D26:D28)
E7=SUM(E5:E6)
E11=E10
E17=SUM(E14:E16)
E22=SUM(E20:E21)
E29=SUM(E26:E28)
P5=SUM(D5:O5)
P6=SUM(D6:O6)
P7=SUM(P5:P6)
P10=SUM(D10:O10)
P11=P10
P14=SUM(D14:O14)
P15=SUM(D15:O15)
P16=SUM(D16:O16)
P17=SUM(P14:P16)
P20=SUM(D20:N20)
P21=SUM(D21:N21)
P22=SUM(D22:N22)
P25=SUM(D25:O25)
P26=SUM(D26:O26)
P27=SUM(D27:O27)
P28=SUM(D28:O28)
P29=SUM(P25:P28)
F11=F10
G11=G10
H11=H10
I11=I10
J11=J10
K11=K10
L11=L10
M11=M10
N11=N10
O11=O10
 
Looks like my typo
Add the dot where shown in red.
Code:
Set Rng = .Range(.Cells(2, Cl),[COLOR=#ff0000][SIZE=4][B] .[/B][/SIZE][/COLOR]Cells(Rows.Count, Cl).End(xlUp))
 
Last edited:
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
No Worries... Its resolved now.

Now i am getting a Subscript Out of Range error in the below linw

Ray(c, 1) = K

Also for displaying Subunits,can we add a condition that we display subunits only when Unit is X.

Thanks,
nitya
 
Last edited:
Upvote 0
Hi,

It is similar data but has 53648 rows.

Also, not sure if this caused the error, the heading of Subunit changed to BG. Here is the current column headers.

Please let me know if you need me to paste 53648 line of data.



Cell Formulas
RangeFormula
A1Category
B1Unit
C1BU
D1BL
E1Market
F1Market Unit
G1Year
H1Period
I1Data
J1Corporate
K1KPI Lifecycle
 
Upvote 0
You could sent a file example through "Box.com" or "DropBox.com" or you could try the code on a limited number of rows, increasing the number of rows until you get the error, then whittle it down to a number of lines in and around that error, then send that data. Just the headers and the data will do!!!
 
Upvote 0
I just thought, should have done it earlier.!!!
Change the line below where it says 100 to 1000 and try again, if necessary Increase as required. ??
Code:
ReDim Ray(1 To 100, 1 To UBound(Hds) + 1)
 
Upvote 0
Hi,

Even when i made it to 2000 i got the same error, then i made a change.

In my sheet i had sub-units for all the units, though i wanted only sub-units of 1 unit displayed. When i removed the sub-units of the other units the code worked.

Ex:

Unit X has sub-units AA,BB,CC,DD
Unit Y has sub-units FF,GG,HH

We need to display only AA,BB,CC,DD and ignore rest. Currently when i cleared the sub-unit column of unit Y, the code worked fine.
 
Upvote 0
Hi,

I am not sure why, but when i put in the old data, it all worked fine...

There are a couple more actions, i need to do on this sheet, should i post in on the same thread or should i start a new one.

Thanks,
Nitya
 
Upvote 0

Forum statistics

Threads
1,215,339
Messages
6,124,365
Members
449,155
Latest member
ravioli44

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