Solved

Summarizing Excel Spreadsheet Data

Posted on 2013-12-05
2
320 Views
Last Modified: 2013-12-06
I have a large excel spreadsheet that has row headings in column 1, and column headings in row 1. At the intersection of certain columns an rows the table has "X" or "x" signs.

The sample table is below
     1e  2f  3g  4h  5k  6l  7m  8n
1a                   X
1b       X
1c        X                X
1d                         X

I need a macro that generates a summary of the table above by generating another spreadsheet by listing the column heading first and then each row heading that has a corresponding X next to it. Based on the example above, the resulting spreadsheet should look like this:

2f, 1b, 1c
4h, 1a
5k, 1c, 1d

Thank you, Experts!
0
Comment
Question by:cyber-33
2 Comments
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
ID: 39700152
Sub tbl2lst()
Dim col As Range
Dim rw As Range
Dim rstr As String
For Each col In Sheet1.Range(Sheet1.Range("B1"), Sheet1.Range("B1").End(xlToRight))
    rstr = col.Value
    For Each rw In Sheet1.Range(Sheet1.Range("A2"), Sheet1.Range("A2").End(xlDown))
    If UCase(Intersect(col.EntireColumn, rw.EntireRow)) = "X" Then
        rstr = rstr & ", " & rw.Value
    End If
    Next rw
    If rstr <> col.Value Then Sheet2.Range("A" & Rows.Count).End(xlUp).Offset(1) = rstr
Next col
End Sub

Open in new window

0
 

Author Closing Comment

by:cyber-33
ID: 39702491
Works like a charm! Thank you!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question