Formatting and Table Change

Pestomania

Active Member
Joined
May 30, 2018
Messages
330
Office Version
  1. 365
Platform
  1. Windows
Hello, I am trying to identify how to take one table and turn it into a different design with a different format. I have about 300 lines of programs that I need to take from the "top" table and turn it into the bottom table.

Thoughts?

Prestons Playground for Modeling.xlsx
ABCDEFGHIJKLMNOPQR
1ProgramProcess 1Process 2Process 3Process 4Process 5Process 6Process 7Process 8Process 9Process 10Process 11Process 12Process 13Process 14Process 15Process 16Total
2Program 12580202786309919710276193
3Program 2138261771120725302827142248267
4Program 332501404102116340241341142
5Program 428181128650210827271529145242
6Program 51163025922720283916199228244
7Program 62617624103400092619902155
8Program 7101333240212127152226272221237
9Program 811800202101711211171213293166
10Program 91524023112120710241161022720231
11Program 101720210170011272271822201614232
12Program 11260140114100222371362295172
13Program 12231614211801921301511027529213
14Program 13131813111402492904122002210199
15Program 142825214939182913281952320227
16
17How to only pull data from the row if the value is greater than 0, then add to a different table, transposed. Make the Program Name equal to column A and put the applicable process name in column D.
18
19
20Program NameStep DurationDays from StartProcess Name
21Program 12193Process 1
22Program 15191Process 2
23Program 18186Process 3
24Program 120178Process 5
25Program 127158Process 6
26Program 18131Process 7
27Program 16123Process 8
28Program 130117Process 9
29Program 1987Process 10
30Program 1978Process 11
31Program 11969Process 12
32Program 1750Process 13
33Program 11043Process 14
34Program 12733Process 15
35Program 166Process 16
36Program 213267Process 1
37Program 28254Process 2
38Program 226246Process 3
39Program 217220Process 4
40Program 27203Process 5
41Program 211196Process 6
42Program 220185Process 7
43Program 27165Process 8
44Program 225158Process 9
45Program 230133Process 10
46Program 228103Process 11
47Program 22775Process 12
48Program 21448Process 13
49Program 2234Process 14
50Program 22432Process 15
51Program 288Process 16
Sheet6
Cell Formulas
RangeFormula
R2:R15R2=SUM(Table6[@[Process 1]:[Process 16]])
C21:C35C21=SUM(B21:$B$35)
C36:C51C36=SUM(B36:$B$51)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:Q15Cell Value=0textNO
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Assuming that you can make (or it already is) Column R part of your table, and I did not do anything with your Headers in the results area, then this code produced these results... Using "Sheet6" and "Table6". The code worked through Program 14, but when I tried to enter the entire results range, XL2BB told me that the Max number of cells was 3,000, so I stopped copying at Program 10.

VBA Code:
Sub TransPoseTable()
    
    Dim i As Long, x As Long, r As Long, lr As Long, lRow As Long, ld As Long, j As Long
    Dim tbl As ListObject: Set tbl = Worksheets("Sheet6").ListObjects("Table6")
    Dim arr, arrL, hdr, arr2, col, colx, arrLD
    Dim tr As Long
     
    hdr = tbl.HeaderRowRange
    r = 1: tr = 1
     
    Do Until tr > tbl.ListRows.Count
        j = 1: i = 1
        arrLD = tbl.ListRows(tr).Range

        'Clean ListRow
        ReDim arrL(1 To 1, 1 To UBound(arrLD, 2))
        For ld = 1 To UBound(arrLD, 2)
            If Not arrLD(1, ld) = 0 Then
                arrL(1, j) = arrLD(1, ld)
                j = j + 1
            End If
        Next

        ReDim Preserve arrL(1 To 1, 1 To j - 1)

        lr = tbl.ListRows(r).Range.Cells.Count
        ReDim col(1 To j - 1, 1 To 4)

        For x = 1 To j - 3
            col(i, 1) = arrL(1, 1)
            col(i, 2) = arrL(1, 1 + i)
            If Not i = 1 Then
                col(i, 3) = col(i - 1, 3) - col(x - r, 2)
            End If
            col(i, 4) = hdr(1, x + 1)
            If i = 1 Then
                col(i, 3) = arrL(1, UBound(arrL, 2))
            End If
            i = i + 1
        Next
        
        lRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
        Range("A" & lRow).Resize(UBound(col), 4) = col
        tr = tr + 1
        If tr > tbl.ListRows.Count Then Exit Sub
        Loop
    
End Sub

Table to new Table.xlsm
ABCDEFGHIJKLMNOPQR
1ProgramProcess 1Process 2Process 3Process 4Process 5Process 6Process 7Process 8Process 9Process 10Process 11Process 12Process 13Process 14Process 15Process 16Total
2Program 12580202786309919710276193
3Program 2138261771120725302827142248267
4Program 332501404102116340241341142
5Program 428181128650210827271529145242
6Program 51163025922720283916199228244
7Program 62617624103400092619902155
8Program 7101333240212127152226272221237
9Program 811800202101711211171213293166
10Program 91524023112120710241161022720231
11Program 101720210170011272271822201614232
12Program 11260140114100222371362295172
13Program 12231614211801921301511027529213
14Program 13131813111402492904122002210199
15Program 142825214939182913281952320227
16
17
18
19
20Program NameStep DurationDays from StartProcess Name
21Program 12193Process 1
22Program 15191Process 2
23Program 18186Process 3
24Program 120178Process 4
25Program 127158Process 5
26Program 18131Process 6
27Program 16123Process 7
28Program 130117Process 8
29Program 1987Process 9
30Program 1978Process 10
31Program 11969Process 11
32Program 1750Process 12
33Program 11043Process 13
34Program 12733Process 14
35Program 166Process 15
36Program 213267Process 1
37Program 28254Process 2
38Program 226246Process 3
39Program 217220Process 4
40Program 27203Process 5
41Program 211196Process 6
42Program 220185Process 7
43Program 27165Process 8
44Program 225158Process 9
45Program 230133Process 10
46Program 228103Process 11
47Program 22775Process 12
48Program 21448Process 13
49Program 2234Process 14
50Program 22432Process 15
51Program 288Process 16
52Program 33142Process 1
53Program 325139Process 2
54Program 314114Process 3
55Program 34100Process 4
56Program 31096Process 5
57Program 32186Process 6
58Program 31665Process 7
59Program 3349Process 8
60Program 3446Process 9
61Program 32442Process 10
62Program 31318Process 11
63Program 345Process 12
64Program 311Process 13
65Program 428242Process 1
66Program 418214Process 2
67Program 411196Process 3
68Program 428185Process 4
69Program 46157Process 5
70Program 45151Process 6
71Program 421146Process 7
72Program 48125Process 8
73Program 427117Process 9
74Program 42790Process 10
75Program 41563Process 11
76Program 42948Process 12
77Program 41419Process 13
78Program 455Process 14
79Program 51244Process 1
80Program 516243Process 2
81Program 530227Process 3
82Program 525197Process 4
83Program 59172Process 5
84Program 52163Process 6
85Program 527161Process 7
86Program 520134Process 8
87Program 528114Process 9
88Program 5386Process 10
89Program 5983Process 11
90Program 51674Process 12
91Program 51958Process 13
92Program 5939Process 14
93Program 52230Process 15
94Program 588Process 16
95Program 626155Process 1
96Program 617129Process 2
97Program 66112Process 3
98Program 624106Process 4
99Program 61082Process 5
100Program 6372Process 6
101Program 6469Process 7
102Program 6965Process 8
103Program 62656Process 9
104Program 61930Process 10
105Program 6911Process 11
106Program 622Process 12
107Program 710237Process 1
108Program 713227Process 2
109Program 73214Process 3
110Program 73211Process 4
111Program 724208Process 5
112Program 72184Process 6
113Program 71182Process 7
114Program 721181Process 8
115Program 727160Process 9
116Program 715133Process 10
117Program 722118Process 11
118Program 72696Process 12
119Program 72770Process 13
120Program 72243Process 14
121Program 72121Process 15
122Program 81166Process 1
123Program 818165Process 2
124Program 820147Process 3
125Program 82127Process 4
126Program 810125Process 5
127Program 817115Process 6
128Program 8198Process 7
129Program 81297Process 8
130Program 81185Process 9
131Program 81774Process 10
132Program 81257Process 11
133Program 81345Process 12
134Program 82932Process 13
135Program 833Process 14
136Program 915231Process 1
137Program 924216Process 2
138Program 923192Process 3
139Program 911169Process 4
140Program 921158Process 5
141Program 920137Process 6
142Program 97117Process 7
143Program 910110Process 8
144Program 924100Process 9
145Program 9176Process 10
146Program 91675Process 11
147Program 91059Process 12
148Program 9249Process 13
149Program 92747Process 14
150Program 92020Process 15
151Program 1017232Process 1
152Program 1020215Process 2
153Program 1021195Process 3
154Program 1017174Process 4
155Program 1011157Process 5
156Program 1027146Process 6
157Program 1022119Process 7
158Program 10797Process 8
159Program 101890Process 9
160Program 102272Process 10
161Program 102050Process 11
162Program 101630Process 12
163Program 101414Process 13
Sheet6
Cell Formulas
RangeFormula
R2:R15R2=SUM(Table6[@[Process 1]:[Process 16]])
 
Upvote 0
Edit: As an update, I have now realized that my code is flawed. Although it is cleaning up the zero value cells, it is not assigning the correct Process number after skipping the zeroes. I am going to try and rework the code to correct it.

In the meantime, hopefully the code I have presented helps you get an idea of what route I am taking to meet your requirements...
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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