Replacing the headers of columns with the contents of the first cell of the rows to the left of it, and deleting columns if their sums = 0

Ocicek

New Member
Joined
May 22, 2021
Messages
8
Office Version
  1. 2019
Platform
  1. Windows
Hi friends.

In excel files provided by Ms Access, which is a group of columns with different column references but specific column headings and ordering;

I want to replace the headers of the named columns with the first cell of the column to the left of these columns and delete them together with the column to the left if the sum of this column is zero.

I haven't been able to find a code that can do this combination. I'm not very good at application matters either.

I tried to explain exactly what I wanted to do with the 3 images attached.

Could someone help me with this?
 

Attachments

  • 1-Replace.png
    1-Replace.png
    145 KB · Views: 8
  • 2-Delete.png
    2-Delete.png
    120.8 KB · Views: 9
  • 3-Result.png
    3-Result.png
    44.1 KB · Views: 9

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
your images are blury and cannot be read. Can you post the worksheet data using the XL2BB tool? See signature for instructions.
 
Upvote 0
Hi friends.

In excel files provided by Ms Access, which is a group of columns with different column references but specific column headings and ordering;

I want to replace the headers of the named columns with the first cell of the column to the left of these columns and delete them together with the column to the left if the sum of this column is zero.

I haven't been able to find a code that can do this combination. I'm not very good at application matters either.

I tried to explain exactly what I wanted to do with the 3 images attached.

Could someone help me with this?
your images are blury and cannot be read. Can you post the worksheet data using the XL2BB tool? See signature for instructions.
S06 2021831835 Table.xlsx
ABCDEFGHIJKLMNOPQR
1
2Some Expenses Table
3StreetUserSize Some Expense Fixed Cost1 Description Fixed Cost1 Fixed Cost2 Description Fixed Cost2 Fixed Cost3 Description Fixed Cost3 Common Area Cost1 Description Common Expense 1 Common Area Cost2 Description Common Expense 2 Common Area Cost3 Description3 Common Expense 3 Billing Cost Payment
4S06S06-01152.49 m²€ 2.54Social Facility Share€ -Service Cost€ 152.49Maintanence Cost€ 152.49Common Area Electricty Share€ 1,029.72Common Area Heating Share€ 8.45Common Area Cost3 Share€ -€ 2.75€ 1,361.13
5S06S06-02149.90 m²€ 2.49Social Facility Share€ -Service Cost€ 149.90Maintanence Cost€ 149.90Common Area Electricty Share€ 1,012.23Common Area Heating Share€ 8.31Common Area Cost3 Share€ -€ 2.75€ 1,331.10
6S06S06-03232.88 m²€ 3.87Social Facility Share€ -Service Cost€ 232.88Maintanence Cost€ 232.88Common Area Electricty Share€ 1,572.57Common Area Heating Share€ 12.91Common Area Cost3 Share€ -€ 2.75€ 2,060.36
7S06S06-04228.70 m²€ 3.80Social Facility Share€ -Service Cost€ 228.70Maintanence Cost€ 228.70Common Area Electricty Share€ 1,544.34Common Area Heating Share€ 12.68Common Area Cost3 Share€ -€ 2.75€ 2,048.51
8S06S06-05241.92 m²€ 4.02Social Facility Share€ -Service Cost€ 241.92Maintanence Cost€ 241.92Common Area Electricty Share€ 1,633.61Common Area Heating Share€ 13.41Common Area Cost3 Share€ -€ 2.75€ 2,191.49
9S06S06-06237.50 m²€ 3.95Social Facility Share€ -Service Cost€ 237.50Maintanence Cost€ 237.50Common Area Electricty Share€ 1,603.77Common Area Heating Share€ 13.17Common Area Cost3 Share€ -€ 2.75€ 2,128.77
10S06S06-07237.50 m²€ 3.95Social Facility Share€ -Service Cost€ 237.50Maintanence Cost€ 237.50Common Area Electricty Share€ 1,603.77Common Area Heating Share€ 13.17Common Area Cost3 Share€ -€ 2.75€ 2,105.99
11771,480.89 m²€ 24.63€ -€ 1,480.89€ 1,480.89€ 10,000.00€ 82.09€ -€ 19.25€ 13,227.36
12
13
14
15
16
Original
Cell Formulas
RangeFormula
A11A11=SUBTOTAL(103,[Street])
B11B11=SUBTOTAL(103,[User])
C11C11=SUBTOTAL(109,[Size])
D11D11=SUBTOTAL(109,[Some Expense])
F11F11=SUBTOTAL(109,[Fixed Cost1])
H11H11=SUBTOTAL(109,[Fixed Cost2])
J11J11=SUBTOTAL(109,[Fixed Cost3])
L11L11=SUBTOTAL(109,[Common Expense 1])
N11N11=SUBTOTAL(109,[Common Expense 2])
P11P11=SUBTOTAL(109,[Common Expense 3])
Q11Q11=SUBTOTAL(109,[Billing Cost])
R11R11=SUBTOTAL(109,[Payment])
 
Upvote 0
S06 2021831835 Table.xlsx
ABCDEFGHIJKLMNOPQR
1
2Some Expenses Table
3StreetUserSize Some Expense Fixed Cost1 Description Fixed Cost1 Fixed Cost2 Description Fixed Cost2 Fixed Cost3 Description Fixed Cost3 Common Area Cost1 Description Common Expense 1 Common Area Cost2 Description Common Expense 2 Common Area Cost3 Description3 Common Expense 3 Billing Cost Payment
4S06S06-01152.49 m²€ 2.54Social Facility Share€ -Service Cost€ 152.49Maintanence Cost€ 152.49Common Area Electricty Share€ 1,029.72Common Area Heating Share€ 8.45Common Area Cost3 Share€ -€ 2.75€ 1,361.13
5S06S06-02149.90 m²€ 2.49Social Facility Share€ -Service Cost€ 149.90Maintanence Cost€ 149.90Common Area Electricty Share€ 1,012.23Common Area Heating Share€ 8.31Common Area Cost3 Share€ -€ 2.75€ 1,331.10
6S06S06-03232.88 m²€ 3.87Social Facility Share€ -Service Cost€ 232.88Maintanence Cost€ 232.88Common Area Electricty Share€ 1,572.57Common Area Heating Share€ 12.91Common Area Cost3 Share€ -€ 2.75€ 2,060.36
7S06S06-04228.70 m²€ 3.80Social Facility Share€ -Service Cost€ 228.70Maintanence Cost€ 228.70Common Area Electricty Share€ 1,544.34Common Area Heating Share€ 12.68Common Area Cost3 Share€ -€ 2.75€ 2,048.51
8S06S06-05241.92 m²€ 4.02Social Facility Share€ -Service Cost€ 241.92Maintanence Cost€ 241.92Common Area Electricty Share€ 1,633.61Common Area Heating Share€ 13.41Common Area Cost3 Share€ -€ 2.75€ 2,191.49
9S06S06-06237.50 m²€ 3.95Social Facility Share€ -Service Cost€ 237.50Maintanence Cost€ 237.50Common Area Electricty Share€ 1,603.77Common Area Heating Share€ 13.17Common Area Cost3 Share€ -€ 2.75€ 2,128.77
10S06S06-07237.50 m²€ 3.95Social Facility Share€ -Service Cost€ 237.50Maintanence Cost€ 237.50Common Area Electricty Share€ 1,603.77Common Area Heating Share€ 13.17Common Area Cost3 Share€ -€ 2.75€ 2,105.99
11771,480.89 m²€ 24.63€ -€ 1,480.89€ 1,480.89€ 10,000.00€ 82.09€ -€ 19.25€ 13,227.36
12
13
14
15
16
Original
Cell Formulas
RangeFormula
A11A11=SUBTOTAL(103,[Street])
B11B11=SUBTOTAL(103,[User])
C11C11=SUBTOTAL(109,[Size])
D11D11=SUBTOTAL(109,[Some Expense])
F11F11=SUBTOTAL(109,[Fixed Cost1])
H11H11=SUBTOTAL(109,[Fixed Cost2])
J11J11=SUBTOTAL(109,[Fixed Cost3])
L11L11=SUBTOTAL(109,[Common Expense 1])
N11N11=SUBTOTAL(109,[Common Expense 2])
P11P11=SUBTOTAL(109,[Common Expense 3])
Q11Q11=SUBTOTAL(109,[Billing Cost])
R11R11=SUBTOTAL(109,[Payment])
S06 2021831835 Table.xlsx
ABCDEFGHIJKLMNOPQR
1
2Some Expenses Table
3StreetUserSize Some Expense Fixed Cost1 Description Fixed Cost1 Fixed Cost2 Description Fixed Cost2 Fixed Cost3 Description Fixed Cost3 Common Area Cost1 Description Common Expense 1 Common Area Cost2 Description Common Expense 2 Common Area Cost3 Description3 Common Expense 3 Billing Cost Payment
4S06S06-01152.49 m²€ 2.54Social Facility Share€ -Service Cost€ 152.49Maintanence Cost€ 152.49Common Area Electricty Share€ 1,029.72Common Area Heating Share€ 8.45Common Area Cost3 Share€ -€ 2.75€ 1,361.13
5S06S06-02149.90 m²€ 2.49Social Facility Share€ -Service Cost€ 149.90Maintanence Cost€ 149.90Common Area Electricty Share€ 1,012.23Common Area Heating Share€ 8.31Common Area Cost3 Share€ -€ 2.75€ 1,331.10
6S06S06-03232.88 m²€ 3.87Social Facility Share€ -Service Cost€ 232.88Maintanence Cost€ 232.88Common Area Electricty Share€ 1,572.57Common Area Heating Share€ 12.91Common Area Cost3 Share€ -€ 2.75€ 2,060.36
7S06S06-04228.70 m²€ 3.80Social Facility Share€ -Service Cost€ 228.70Maintanence Cost€ 228.70Common Area Electricty Share€ 1,544.34Common Area Heating Share€ 12.68Common Area Cost3 Share€ -€ 2.75€ 2,048.51
8S06S06-05241.92 m²€ 4.02Social Facility Share€ -Service Cost€ 241.92Maintanence Cost€ 241.92Common Area Electricty Share€ 1,633.61Common Area Heating Share€ 13.41Common Area Cost3 Share€ -€ 2.75€ 2,191.49
9S06S06-06237.50 m²€ 3.95Social Facility Share€ -Service Cost€ 237.50Maintanence Cost€ 237.50Common Area Electricty Share€ 1,603.77Common Area Heating Share€ 13.17Common Area Cost3 Share€ -€ 2.75€ 2,128.77
10S06S06-07237.50 m²€ 3.95Social Facility Share€ -Service Cost€ 237.50Maintanence Cost€ 237.50Common Area Electricty Share€ 1,603.77Common Area Heating Share€ 13.17Common Area Cost3 Share€ -€ 2.75€ 2,105.99
11771,480.89 m²€ 24.63€ -€ 1,480.89€ 1,480.89€ 10,000.00€ 82.09€ -€ 19.25€ 13,227.36
12
13
14
15
16
Original
Cell Formulas
RangeFormula
A11A11=SUBTOTAL(103,[Street])
B11B11=SUBTOTAL(103,[User])
C11C11=SUBTOTAL(109,[Size])
D11D11=SUBTOTAL(109,[Some Expense])
F11F11=SUBTOTAL(109,[Fixed Cost1])
H11H11=SUBTOTAL(109,[Fixed Cost2])
J11J11=SUBTOTAL(109,[Fixed Cost3])
L11L11=SUBTOTAL(109,[Common Expense 1])
N11N11=SUBTOTAL(109,[Common Expense 2])
P11P11=SUBTOTAL(109,[Common Expense 3])
Q11Q11=SUBTOTAL(109,[Billing Cost])
R11R11=SUBTOTAL(109,[Payment])
S06 2021831835 Table.xlsx
ABCDEFGHIJKLMNOPQR
1Columns to be processed. These columns always come in this title and order, but they may start in different places in different excel files.
2Some Expenses Table
3StreetUserSize Some Expense Fixed Cost1 DescriptionSocial Facility ShareFixed Cost2 DescriptionService CostFixed Cost3 DescriptionMaintanence CostCommon Area Cost1 DescriptionCommon Area Electricty ShareCommon Area Cost2 DescriptionCommon Area Heating ShareCommon Area Cost3 DescriptionCommon Area Cost3 Description2 Billing cost Payment
4S06S06-01152.49 m²€ 2.54Social Facility Share€ -Service Cost€ 152.49Maintanence Cost€ 152.49Common Area Electricty Share€ 1,029.72Common Area Heating Share€ 8.45Common Area Cost3 Description€ -€ 2.75€ 1,361.13
5S06S06-02149.90 m²€ 2.49Social Facility Share€ -Service Cost€ 149.90Maintanence Cost€ 149.90Common Area Electricty Share€ 1,012.23Common Area Heating Share€ 8.31Common Area Cost3 Description€ -€ 2.75€ 1,331.10
6S06S06-03232.88 m²€ 3.87Social Facility Share€ -Service Cost€ 232.88Maintanence Cost€ 232.88Common Area Electricty Share€ 1,572.57Common Area Heating Share€ 12.91Common Area Cost3 Description€ -€ 2.75€ 2,060.36
7S06S06-04228.70 m²€ 3.80Social Facility Share€ -Service Cost€ 228.70Maintanence Cost€ 228.70Common Area Electricty Share€ 1,544.34Common Area Heating Share€ 12.68Common Area Cost3 Description€ -€ 2.75€ 2,048.51
8S06S06-05241.92 m²€ 4.02Social Facility Share€ -Service Cost€ 241.92Maintanence Cost€ 241.92Common Area Electricty Share€ 1,633.61Common Area Heating Share€ 13.41Common Area Cost3 Description€ -€ 2.75€ 2,191.49
9S06S06-06237.50 m²€ 3.95Social Facility Share€ -Service Cost€ 237.50Maintanence Cost€ 237.50Common Area Electricty Share€ 1,603.77Common Area Heating Share€ 13.17Common Area Cost3 Description€ -€ 2.75€ 2,128.77
10S06S06-07237.50 m²€ 3.95Social Facility Share€ -Service Cost€ 237.50Maintanence Cost€ 237.50Common Area Electricty Share€ 1,603.77Common Area Heating Share€ 13.17Common Area Cost3 Description€ -€ 2.75€ 2,105.99
11771,480.89 m²€ 24.63€ -€ 1,480.89€ 1,480.89€ 10,000.00€ 82.09€ -€ 19.25€ 13,227.36
12The table always comes with the name Table1 and always starts in cell A3, expanding right and down according to the number of columns and rows.
13
14
Replacing Headers
Cell Formulas
RangeFormula
A11A11=SUBTOTAL(103,[Street])
B11B11=SUBTOTAL(103,[User])
C11C11=SUBTOTAL(109,[Size])
D11D11=SUBTOTAL(109,[Some Expense])
F11F11=SUBTOTAL(109,[Social Facility Share])
H11H11=SUBTOTAL(109,[Service Cost])
J11J11=SUBTOTAL(109,[Maintanence Cost])
L11L11=SUBTOTAL(109,[Common Area Electricty Share])
N11N11=SUBTOTAL(109,[Common Area Heating Share])
P11P11=SUBTOTAL(109,[Common Area Cost3 Description2])
Q11Q11=SUBTOTAL(109,[Billing cost])
R11R11=SUBTOTAL(109,[Payment])
 
Upvote 0
S06 2021831835 Table.xlsx
ABCDEFGHIJKLMNOPQR
1Columns to be processed. These columns always come in this title and order, but they may start in different places in different excel files.
2Some Expenses Table
3StreetUserSize Some Expense Fixed Cost1 DescriptionSocial Facility ShareFixed Cost2 DescriptionService CostFixed Cost3 DescriptionMaintanence CostCommon Area Cost1 DescriptionCommon Area Electricty ShareCommon Area Cost2 DescriptionCommon Area Heating ShareCommon Area Cost3 DescriptionCommon Area Cost3 Description2 Billing cost Payment
4S06S06-01152.49 m²€ 2.54Social Facility Share€ -Service Cost€ 152.49Maintanence Cost€ 152.49Common Area Electricty Share€ 1,029.72Common Area Heating Share€ 8.45Common Area Cost3 Description€ -€ 2.75€ 1,361.13
5S06S06-02149.90 m²€ 2.49Social Facility Share€ -Service Cost€ 149.90Maintanence Cost€ 149.90Common Area Electricty Share€ 1,012.23Common Area Heating Share€ 8.31Common Area Cost3 Description€ -€ 2.75€ 1,331.10
6S06S06-03232.88 m²€ 3.87Social Facility Share€ -Service Cost€ 232.88Maintanence Cost€ 232.88Common Area Electricty Share€ 1,572.57Common Area Heating Share€ 12.91Common Area Cost3 Description€ -€ 2.75€ 2,060.36
7S06S06-04228.70 m²€ 3.80Social Facility Share€ -Service Cost€ 228.70Maintanence Cost€ 228.70Common Area Electricty Share€ 1,544.34Common Area Heating Share€ 12.68Common Area Cost3 Description€ -€ 2.75€ 2,048.51
8S06S06-05241.92 m²€ 4.02Social Facility Share€ -Service Cost€ 241.92Maintanence Cost€ 241.92Common Area Electricty Share€ 1,633.61Common Area Heating Share€ 13.41Common Area Cost3 Description€ -€ 2.75€ 2,191.49
9S06S06-06237.50 m²€ 3.95Social Facility Share€ -Service Cost€ 237.50Maintanence Cost€ 237.50Common Area Electricty Share€ 1,603.77Common Area Heating Share€ 13.17Common Area Cost3 Description€ -€ 2.75€ 2,128.77
10S06S06-07237.50 m²€ 3.95Social Facility Share€ -Service Cost€ 237.50Maintanence Cost€ 237.50Common Area Electricty Share€ 1,603.77Common Area Heating Share€ 13.17Common Area Cost3 Description€ -€ 2.75€ 2,105.99
11771,480.89 m²€ 24.63€ -€ 1,480.89€ 1,480.89€ 10,000.00€ 82.09€ -€ 19.25€ 13,227.36
12The table always comes with the name Table1 and always starts in cell A3, expanding right and down according to the number of columns and rows.
13
14
Replacing Headers
Cell Formulas
RangeFormula
A11A11=SUBTOTAL(103,[Street])
B11B11=SUBTOTAL(103,[User])
C11C11=SUBTOTAL(109,[Size])
D11D11=SUBTOTAL(109,[Some Expense])
F11F11=SUBTOTAL(109,[Social Facility Share])
H11H11=SUBTOTAL(109,[Service Cost])
J11J11=SUBTOTAL(109,[Maintanence Cost])
L11L11=SUBTOTAL(109,[Common Area Electricty Share])
N11N11=SUBTOTAL(109,[Common Area Heating Share])
P11P11=SUBTOTAL(109,[Common Area Cost3 Description2])
Q11Q11=SUBTOTAL(109,[Billing cost])
R11R11=SUBTOTAL(109,[Payment])
I am sorry I am using XLBB tool first time. I did want to post what I want to do 3 step xlbb.
S06 2021831835 Table.xlsx
ABCDEFGHIJKLMNOPQR
1
2Some Expenses TableDescription Column that will be deleted Sum=0 Column that will be deleted Description Column that will be deletedDescription Column that will be deletedDescription Column that will be deletedDescription Column that will be deletedDescription Column that will be deleted Sum=0 Column that will be deleted
3StreetUserSize Some Expense Fixed Cost1 DescriptionSocial Facility ShareFixed Cost2 DescriptionService CostFixed Cost3 DescriptionMaintanence CostCommon Area Cost1 DescriptionCommon Area Electricty ShareCommon Area Cost2 DescriptionCommon Area Heating ShareCommon Area Cost3 DescriptionCommon Area Cost3 Description2 Billing cost Payment
4S06S06-01152.49 m²€ 2.54Social Facility Share€ -Service Cost€ 152.49Maintanence Cost€ 152.49Common Area Electricty Share€ 1,029.72Common Area Heating Share€ 8.45Common Area Cost3 Description€ -€ 2.75€ 1,361.13
5S06S06-02149.90 m²€ 2.49Social Facility Share€ -Service Cost€ 149.90Maintanence Cost€ 149.90Common Area Electricty Share€ 1,012.23Common Area Heating Share€ 8.31Common Area Cost3 Description€ -€ 2.75€ 1,331.10
6S06S06-03232.88 m²€ 3.87Social Facility Share€ -Service Cost€ 232.88Maintanence Cost€ 232.88Common Area Electricty Share€ 1,572.57Common Area Heating Share€ 12.91Common Area Cost3 Description€ -€ 2.75€ 2,060.36
7S06S06-04228.70 m²€ 3.80Social Facility Share€ -Service Cost€ 228.70Maintanence Cost€ 228.70Common Area Electricty Share€ 1,544.34Common Area Heating Share€ 12.68Common Area Cost3 Description€ -€ 2.75€ 2,048.51
8S06S06-05241.92 m²€ 4.02Social Facility Share€ -Service Cost€ 241.92Maintanence Cost€ 241.92Common Area Electricty Share€ 1,633.61Common Area Heating Share€ 13.41Common Area Cost3 Description€ -€ 2.75€ 2,191.49
9S06S06-06237.50 m²€ 3.95Social Facility Share€ -Service Cost€ 237.50Maintanence Cost€ 237.50Common Area Electricty Share€ 1,603.77Common Area Heating Share€ 13.17Common Area Cost3 Description€ -€ 2.75€ 2,128.77
10S06S06-07237.50 m²€ 3.95Social Facility Share€ -Service Cost€ 237.50Maintanence Cost€ 237.50Common Area Electricty Share€ 1,603.77Common Area Heating Share€ 13.17Common Area Cost3 Description€ -€ 2.75€ 2,105.99
11771,480.89 m²€ 24.63€ -€ 1,480.89€ 1,480.89€ 10,000.00€ 82.09€ -€ 19.25€ 13,227.36
12
Del Descr and Sum0 Columns
Cell Formulas
RangeFormula
A11A11=SUBTOTAL(103,[Street])
B11B11=SUBTOTAL(103,[User])
C11C11=SUBTOTAL(109,[Size])
D11D11=SUBTOTAL(109,[Some Expense])
F11F11=SUBTOTAL(109,[Social Facility Share])
H11H11=SUBTOTAL(109,[Service Cost])
J11J11=SUBTOTAL(109,[Maintanence Cost])
L11L11=SUBTOTAL(109,[Common Area Electricty Share])
N11N11=SUBTOTAL(109,[Common Area Heating Share])
P11P11=SUBTOTAL(109,[Common Area Cost3 Description2])
Q11Q11=SUBTOTAL(109,[Billing cost])
R11R11=SUBTOTAL(109,[Payment])
 
Upvote 0
Thanks for those! They were extremely helpful in understanding what you wanted.

Assumptions I made:
1. If a column header contains the word "Description" then the next column header name should be made the value of the first row of data from the "Description" column
2. The "Description" column can then be deleted
3. If a column has a total = 0 then it should be deleted

Give your original data
Book1
ABCDEFGHIJKLMNOPQR
3StreetUserSizeSome ExpenseFixed Cost1 DescriptionFixed Cost1Fixed Cost2 DescriptionFixed Cost2Fixed Cost3 DescriptionFixed Cost3Common Area Cost1 DescriptionCommon Expense 1Common Area Cost2 DescriptionCommon Expense 2Common Area Cost3 Description3Common Expense 3Billing CostPayment
4S06S06-01152.492.535925748Social Facility Share0Service Cost152.49Maintanence Cost152.49Common Area Electricty Share1029.718615Common Area Heating Share8.453085843Common Area Cost3 Share02.751361.1256
5S06S06-02149.92.492853759Social Facility Share0Service Cost149.9Maintanence Cost149.9Common Area Electricty Share1012.229132Common Area Heating Share8.309512544Common Area Cost3 Share02.751331.10218
6S06S06-03232.883.872820436Social Facility Share0Service Cost232.88Maintanence Cost232.88Common Area Electricty Share1572.567848Common Area Heating Share12.90940148Common Area Cost3 Share02.752060.36416
7S06S06-04228.73.803306569Social Facility Share0Service Cost228.7Maintanence Cost228.7Common Area Electricty Share1544.341578Common Area Heating Share12.67768859Common Area Cost3 Share02.752048.51158
8S06S06-05241.924.023156647Social Facility Share0Service Cost241.92Maintanence Cost241.92Common Area Electricty Share1633.61222Common Area Heating Share13.41052218Common Area Cost3 Share02.752191.48868
9S06S06-06237.53.949651553Social Facility Share0Service Cost237.5Maintanence Cost237.5Common Area Electricty Share1603.765303Common Area Heating Share13.1655052Common Area Cost3 Share02.752128.77368
10S06S06-07237.53.949651553Social Facility Share0Service Cost237.5Maintanence Cost237.5Common Area Electricty Share1603.765303Common Area Heating Share13.1655052Common Area Cost3 Share02.752105.99479
11771,480.8924.63-1,480.891,480.8910,000.0082.09-19.2513,227.36
Original Data
Cell Formulas
RangeFormula
A11A11=SUBTOTAL(3,[Street])
B11B11=SUBTOTAL(3,[User])
C11C11=SUBTOTAL(109,[Size])
D11D11=SUBTOTAL(109,[Some Expense])
F11F11=SUBTOTAL(109,[Fixed Cost1])
H11H11=SUBTOTAL(109,[Fixed Cost2])
J11J11=SUBTOTAL(109,[Fixed Cost3])
L11L11=SUBTOTAL(109,[Common Expense 1])
N11N11=SUBTOTAL(109,[Common Expense 2])
P11P11=SUBTOTAL(109,[Common Expense 3])
Q11Q11=SUBTOTAL(109,[Billing Cost])
R11R11=SUBTOTAL(109,[Payment])


Using this code
VBA Code:
Sub RenameAndDeleteTableColumns()
    Dim ws As Worksheet
    Dim tbl As ListObject
    Dim i As Long
    
    Set ws = ThisWorkbook.Worksheets(ActiveSheet.Name)
    
    If ws.ListObjects.Count <> 1 Then Exit Sub
    
    Set tbl = ws.ListObjects(1)
    
    i = 1
    
    While i <= tbl.ListColumns.Count
        If tbl.ListColumns(i).Name Like "*Description*" Then
            tbl.ListColumns(i + 1).Name = tbl.DataBodyRange(1, i).Value
            tbl.ListColumns(i).Delete
            i = i - 1
        Else
            If tbl.ListColumns(i).Total = 0 Then
                tbl.ListColumns(i).Delete
                i = i - 1
            End If
        End If
        i = i + 1
    Wend
End Sub

I get this output
Book1
ABCDEFGHIJ
3StreetUserSizeSome ExpenseService CostMaintanence CostCommon Area Electricty ShareCommon Area Heating ShareBilling CostPayment
4S06S06-01152.492.535925748152.49152.491029.7186158.4530858432.751361.125602
5S06S06-02149.92.492853759149.9149.91012.2291328.3095125442.751331.102182
6S06S06-03232.883.872820436232.88232.881572.56784812.909401482.752060.36416
7S06S06-04228.73.803306569228.7228.71544.34157812.677688592.752048.511584
8S06S06-05241.924.023156647241.92241.921633.6122213.410522182.752191.488682
9S06S06-06237.53.949651553237.5237.51603.76530313.16550522.752128.773685
10S06S06-07237.53.949651553237.5237.51603.76530313.16550522.752105.994792
11771,480.8924.631,480.891,480.8910,000.0082.0919.2513,227.36
Original Data (2)
Cell Formulas
RangeFormula
A11A11=SUBTOTAL(3,[Street])
B11B11=SUBTOTAL(3,[User])
C11C11=SUBTOTAL(109,[Size])
D11D11=SUBTOTAL(109,[Some Expense])
E11E11=SUBTOTAL(109,[Service Cost])
F11F11=SUBTOTAL(109,[Maintanence Cost])
G11G11=SUBTOTAL(109,[Common Area Electricty Share])
H11H11=SUBTOTAL(109,[Common Area Heating Share])
I11I11=SUBTOTAL(109,[Billing Cost])
J11J11=SUBTOTAL(109,[Payment])
 
Upvote 0

Forum statistics

Threads
1,214,914
Messages
6,122,211
Members
449,074
Latest member
cancansova

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