Converting Table to "Flat File"

zippyfrog

New Member
Joined
Feb 26, 2021
Messages
2
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi - I am new to this forum and not sure what the best way to ask this is. Or even if I am using the right terms. Right now I have a spreadsheet that is acting as a table to represent data. What I want to do is convert the table into rows of data so that I can manipulate it in Access. My data represents student names and then across the top are the 50 test questions. In Excel, I am putting an "x" in each cell whenever a student gets a question wrong. What I would like to do is be able to someone covert the table into a flat file so when I import it into Access I can do more with the data.

Here is what I have setup. On Sheet 1, the top row contains the question number. The first column contains the student name, then whenever there is an "x" that indicates a wrong question. This is on the first tab, which I called data. Then, on the second tab, which I called listing, is what I would like to have the results be. The student name and then next to the name the question they got wrong. One line per question.

I tried searching online but I am not sure if I am even describing this correctly...

Any help you could give would be appreciated. Thanks in advance!

Sample Data.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAGAHAIAJAKALAMANAOAPAQARASATAUAVAWAXAY
11234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
2Chrisxxxxx
3Jonxxxxxx
4Sallyxxxxx
Data


Sample Data.xlsx
AB
1Chris4
2Chris13
3Chris31
4Chris40
5Chris49
6Jon2
7Jon10
8Jon20
9Jon31
10Jon45
11Jon50
12Sally2
13Sally14
14Sally25
15Sally38
16Sally47
Listing
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Hi & welcome to MrExcel.
How about
VBA Code:
Sub zipyfrog()
   Dim Ary As Variant, Nary As Variant
   Dim r As Long, c As Long, nr As Long
   
   With Sheets("Data")
      Ary = .Range("A1:AY" & .Range("A" & Rows.Count).End(xlUp).Row).Value2
   End With
   ReDim Nary(1 To UBound(Ary) * UBound(Ary, 2), 1 To 2)
   
   For r = 2 To UBound(Ary)
      For c = 2 To UBound(Ary, 2)
         If Ary(r, c) = "x" Then
            nr = nr + 1
            Nary(nr, 1) = Ary(r, 1)
            Nary(nr, 2) = Ary(1, c)
         End If
      Next c
   Next r
   Sheets("Listing").Range("A2").Resize(nr, 2).Value = Nary
End Sub
 
Upvote 0
Solution
That is exactly what I needed! Thanks! I couldn't find that anywhere online.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,826
Messages
6,121,797
Members
449,048
Latest member
greyangel23

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