Date Auto-fill via numbers in external table

jordanblair07

New Member
Joined
Jun 11, 2015
Messages
3
Hello,

I am not completely sure if this is possible, I have a table like below:

ABCDEFGH
7/1/2015150024003600
7/2/2015150015003600
7/3/2015160024003600
7/4/2015160036001800
7/5/2015240036001600
ETC....

<tbody>
</tbody>


If a cell in column A - H has a number I want it to populate the date that the number corresponds with to another table. So if columnds A - H have 3 cells filled with numbers I should have three lines dated with 7/1/2015. Example below,

7/1/20151500
7/1/20152400
7/1/20153600
7/2/20151500
7/2/20151500
7/2/20153600
7/3/2015 ETC...1600

<tbody>
</tbody>

Then if a number is removed or additional number is added on that day the second table adjusts to include date and number.

I would prefer this to be done with a formula over a macor but what would be the easiest and most flexible way, so if changes are made a lot on the table the second table can adjust easily.

Thank you for the assistance in advanced!!!
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Hello,

not sure if formula is possible, but macro below should work. Have assumed your dates are in Column A and values are in B to I.

Code:
Sub REORDER_TABLE()
     Sheets("Sheet2").Columns("A:B").ClearContents
    Application.ScreenUpdating = False
    For MY_ROWS = 2 To Range("A" & Rows.Count).End(xlUp).Row
        For MY_COLS = 2 To 9
            If Not (IsEmpty(Cells(MY_ROWS, MY_COLS).Value)) Then
                With Sheets("Sheet2")
                    .Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Value = Sheets("Sheet1").Cells(MY_ROWS, 1).Value
                    .Range("B" & Rows.Count).End(xlUp).Offset(1, 0).Value = Sheets("Sheet1").Cells(MY_ROWS, MY_COLS).Value
                End With
            End If
        Next MY_COLS
    Next MY_ROWS
    Application.ScreenUpdating = True
End Sub

you can run this code whenever required.
 
Upvote 0
This is great!! Works how I want it to, thank you!!

Question for future reference, If I were to change were the dates were located, from the side to the top with the numbers going down. How would I change the macro? I tried adjusting myself but I am missing something, thank you for the help!
 
Upvote 0
Hello,

does this work as expected?
Code:
Sub REORDER_TABLE_2()
    Sheets("Sheet2").Columns("A:B").ClearContents
    Application.ScreenUpdating = False
    For MY_COLS = 1 To Cells(1, Columns.Count).End(xlToLeft).Column
        For MY_ROWS = 2 To Cells(Rows.Count, MY_COLS).End(xlUp).Row
            If Not (IsEmpty(Cells(MY_ROWS, MY_COLS).Value)) Then
                With Sheets("Sheet2")
                    .Range("A" & Rows.Count).End(xlUp).Offset(1, 0).Value = Sheets("Sheet1").Cells(1, MY_COLS).Value
                    .Range("B" & Rows.Count).End(xlUp).Offset(1, 0).Value = Sheets("Sheet1").Cells(MY_ROWS, MY_COLS).Value
                End With
            End If
        Next MY_ROWS
    Next MY_COLS
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,383
Members
448,955
Latest member
BatCoder

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