Spread sheet table into list that updates

marktwo

New Member
Joined
Sep 7, 2014
Messages
3
Hello there, Here's my query I have a Spreadsheet table with entries per month that I want to turn into a list that updates with new information as it is entered - this far I have been able to get BUT I don't want to see the nil or Zero entries in my list as it makes it too bulky see example below (as I'd like to see it working new entry in red):

Spreadsheet

Jan Feb Mar Apr
A 1 11 20 31
B 2 21 32
C 12 22
D 3 13 33

List

Jan
A 1
B 2
D 3

Feb
A 11
C 12
D 13

Mar
B 21
C 22

Apr
A 31
B 32
D 33

New Entry For March updates to:
Mar
A 20
B 21
C 22


I have tried a filter but this doesn't update?

Am I missing something or is there an elegant solution??


Many thanks in advance

Marktwo
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Welcome to MrExcel.

Formulas in G2:H2 copied down as far as you think they will be needed:


Excel 2010
ABCDEFGH
1JanFebMarAprJan
2A1112031A1
3B22132B2
4C1222D3
5D31333
Sheet1
Cell Formulas
RangeFormula
G2{=IFERROR(INDEX($A$2:A$5,SMALL(IF(INDEX(B$2:E$5,0,MATCH($G$1,B$1:E$1,FALSE))<>"",ROW(A$2:A$5)-ROW(A$2)+1),ROWS(G$2:G2))),"")}
H2{=IFERROR(INDEX(INDEX(B$2:E$5,0,MATCH($G$1,B$1:E$1,FALSE)),SMALL(IF(INDEX(B$2:E$5,0,MATCH($G$1,B$1:E$1,FALSE))<>"",ROW(A$2:A$5)-ROW(A$2)+1),ROWS(G$2:G2))),"")}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Run this macro on a dummy of your sheet

Code:
Sub CONVERTROWSTOCOL_Oeldere_revisted_new()

Dim rsht1 As Long, rsht2 As Long, I As Long, col As Long, wsTest As Worksheet, mr As Worksheet, ms As Worksheet

'check if sheet "ouput" already exist

Const strSheetName As String = "Output"                      'I had to add this row

Set wsTest = Nothing
On Error Resume Next
Set wsTest = ActiveWorkbook.Worksheets(strSheetName)
On Error GoTo 0
 
If wsTest Is Nothing Then
    Worksheets.Add.Name = strSheetName
End If

'set the data
                 

Set mr = Sheets("sheet1")                                  'this is the name of the source sheet
 
Set ms = Sheets("Output")                                       'this is the name of the destiny sheet

col = 2
'End set the data

    With ms
     .UsedRange.ClearContents
     .Range("A1:C1").Value = Array("Issue", "Month", "value")
    End With
    
    rsht2 = ms.Range("A" & Rows.Count).End(xlUp).Row
    
    
    With mr
          rsht1 = .Range("A" & .Rows.Count).End(xlUp).Row
          For I = 2 To rsht1
                Do While .Cells(1, col).Value <> "" 'And .Cells(I, col).Value <> ""
                rsht2 = rsht2 + 1
               
                ms.Range("A" & rsht2).Value = .Range("A" & I).Value
                
                ms.Range("B" & rsht2).Value = .Cells(1, col).Value
                
                ms.Range("C" & rsht2).Value = .Cells(I, col).Value
         
                col = col + 1
            Loop
            col = 2
        Next
    End With
    
  With ms
    .Range("C2:C" & .Rows.Count).SpecialCells(4).EntireRow.Delete
    
    .Range("C2:C" & .Rows.Count).RemoveDuplicates , Header:=xlYes
    
   
    .Columns("A:Z").EntireColumn.AutoFit
    
    End With
    
End Sub
 
Upvote 0
Welcome to the MrExcel board!

If you want the list layout shown without multiple empty rows if a particular month has no, or few, entries then I don't think a formula solution would be feasible.

I'm suggesting a macro using the Worksheet_Change event so the list should update automatically whenever something is changed in the data area.
Test in a copy of your workbook.

To implement ..

1. Right click the sheet name tab and choose "View Code".

2. Copy and Paste the code below into the main right hand pane that opens at step 1.

3. Close the Visual Basic window & test.

4. If using Excel 2007 or later your workbook will need to be saved as a macro-enabled workbook (*.xlsm)

Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim cols As Long, rws As Long, i As Long, j As Long, k As Long
  Dim a, b
  
  Const DataRows As String = "1:5"  '<- Rows to monitor, include header row
  Const ListHeaderRow As Long = 7  '<- Row the word 'List' is in
  
  If Not Intersect(Target, Rows(DataRows)) Is Nothing Then
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    rws = Rows(DataRows).Rows.Count
    cols = Cells(1, Columns.Count).End(xlToLeft).Column
    a = Rows(DataRows).Resize(, cols).Value
    ReDim b(1 To cols * rws, 1 To 2)
    For j = 2 To cols
      k = k + 2
      b(k, 1) = a(1, j)
      For i = 2 To cols
        If a(i, j) <> "" Then
          k = k + 1
          b(k, 1) = a(i, 1)
          b(k, 2) = a(i, j)
        End If
      Next i
    Next j
    Range("A" & ListHeaderRow + 1, Range("A" & Rows.Count).End(xlUp)).Resize(, 2).ClearContents
    Cells(ListHeaderRow + 1, 1).Resize(k, 2).Value = b
    Application.ScreenUpdating = True
    Application.EnableEvents = True
  End If
End Sub

Entering the data shown in rows 1:5 produces the output in rows 9 onwards.

Excel Workbook
ABCDEF
1JanFebMarApr
2A11131
3B22132
4C1222*
5D31333
6
7List
8
9Jan
10A1
11B2
12D3
13
14Feb
15A11
16C12
17D13
18
19Mar
20B21
21C22*
22
23Apr
24A31
25B32
26D33
27
Update List





Then entering 20 in cell D2 produces this:

Excel Workbook
ABCDEF
1JanFebMarApr
2A1112031
3B22132
4C1222*
5D31333
6
7List
8
9Jan
10A1
11B2
12D3
13
14Feb
15A11
16C12
17D13
18
19Mar
20A20
21B21
22C22*
23
24Apr
25A31
26B32
27D33
28
Update List
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

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