IF > 0 THEN return corresponding Column & Row Header; for times the value occurred on each date

qadeerahmed

New Member
Joined
Nov 5, 2015
Messages
6
I' have a question somewhat similar to this post, but with some difference.

https://www.mrexcel.com/forum/excel...column-header-row-header-each-occurrence.html

01-JAN-1702-JAN-1703-JAN-1704-JAN-1705-JAN-1706-JAN-1707-JAN-17
99XX10020103110
99XX10030201300
99XX10040000001
99RN10052005000

<tbody>
</tbody>
what I 'm looking is...

IF > 0 THEN return corresponding Column & Row Header; for times the value occurred on each date

e.g.
99xx1002 occurred 1 time on "02-Jan-17" and 3 times on "04-Jan-17 and 1 time on 05/06 jan....

I want to put this into tabular form like....
99xx100202-jan-17
99xx100204-Jan-17
99xx100204-Jan-17
99xx100204-Jan-17
99xx100205-Jan-17
99xx100206-jan-17
99xx100302-jan-17
99xx100302-jan-17

<tbody>
</tbody>

Appreciate for your time and help:)

Thanks!

<tbody>
</tbody><colgroup><col span="8"></colgroup>
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Book1
ABCDEFGH
101-Jan-1702-Jan-1703-Jan-1704-Jan-1705-Jan-1706-Jan-1707-Jan-17
299XX10020103110
399XX10030201300
499XX10040000001
599RN10052005000
Sheet1


This code will put a new table underneath:

Code:
Public Sub WBD2017052301()

Dim lastCol As Long
Dim lastRow As Long
Dim thisCol As Long
Dim thisRow As Long
Dim cellValue As Variant
Dim nextRow As Long

lastCol = Cells(1, Columns.Count).End(xlToLeft).Column
lastRow = Cells(Rows.Count, 1).End(xlUp).Row

nextRow = lastRow + 2

For thisRow = 2 To lastRow
    For thisCol = 2 To lastCol
        cellValue = Cells(thisRow, thisCol).Value
        While cellValue > 0
            Cells(nextRow, 1) = Cells(thisRow, 1)
            Cells(nextRow, 1).NumberFormat = Cells(thisRow, 1).NumberFormat
            Cells(nextRow, 2) = Cells(1, thisCol)
            Cells(nextRow, 2).NumberFormat = Cells(1, thisCol).NumberFormat
            nextRow = nextRow + 1
            cellValue = cellValue - 1
        Wend
    Next thisCol
Next thisRow
    
End Sub

Like this:


Book1
AB
799XX100202-Jan-17
899XX100204-Jan-17
999XX100204-Jan-17
1099XX100204-Jan-17
1199XX100205-Jan-17
1299XX100206-Jan-17
1399XX100302-Jan-17
1499XX100302-Jan-17
1599XX100304-Jan-17
1699XX100305-Jan-17
1799XX100305-Jan-17
1899XX100305-Jan-17
1999XX100407-Jan-17
2099RN100501-Jan-17
2199RN100501-Jan-17
2299RN100504-Jan-17
2399RN100504-Jan-17
2499RN100504-Jan-17
2599RN100504-Jan-17
2699RN100504-Jan-17
Sheet1


WBD
 
Upvote 0

Forum statistics

Threads
1,214,639
Messages
6,120,679
Members
448,977
Latest member
dbonilla0331

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