Formula to make a record sheet out of a report..

omairhe

Well-known Member
Joined
Mar 26, 2009
Messages
2,040
Office Version
  1. 2019
Platform
  1. Windows
Hello all,

I'm trying to get a record stored for later use from a givenreport for the month of February, 2018. Because the report is Excel based Iwould like to store the data in such a way that Pivot table can be used for anyfuture requirements.

Currently the report looks like this...

Ha3EYUa.png




However my goal is to achieve something like theimage below in a new sheet:-

Ha3HIMc.png



Will appreciate a formula more than a Vbascript. But either way it will mean the world to me...
Tk you.

regards,
omair
<!--[if !supportLineBreakNewLine]-->
<!--[endif]-->
 

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)
Code:
Sub FormatTable()
    Dim wb As Workbook
    Dim s As Worksheet, ss As Worksheet
    Dim r As Long, c As Long, pr As Long


    Set wb = ThisWorkbook 'Workbooks("Book1.xlsx")
    Set s = wb.Worksheets("Sheet1")
    Set ss = wb.Worksheets.Add(After:=s)
    pr = 1


    For c = 2 To s.Cells(1, Columns.Count).End(xlToLeft).Column
        For r = 2 To s.Cells(s.Rows.Count, 1).End(xlUp).Row
            ss.Cells(pr, 1).Value = s.Cells(r, 1).Value
            ss.Cells(pr, 2).Value = s.Cells(1, c).Value
            ss.Cells(pr, 3).Value = s.Cells(r, c).Value


            pr = pr + 1
        Next r
    Next c
End Sub

this would do it
 
Last edited:
Upvote 0
Thank you... I appreciate it a lot.

Code:
Sub FormatTable()
    Dim wb As Workbook
    Dim s As Worksheet, ss As Worksheet
    Dim r As Long, c As Long, pr As Long


    Set wb = ThisWorkbook 'Workbooks("Book1.xlsx")
    Set s = wb.Worksheets("Sheet1")
    Set ss = wb.Worksheets.Add(After:=s)
    pr = 1


    For c = 2 To s.Cells(1, Columns.Count).End(xlToLeft).Column
        For r = 2 To s.Cells(s.Rows.Count, 1).End(xlUp).Row
            ss.Cells(pr, 1).Value = s.Cells(r, 1).Value
            ss.Cells(pr, 2).Value = s.Cells(1, c).Value
            ss.Cells(pr, 3).Value = s.Cells(r, c).Value


            pr = pr + 1
        Next r
    Next c
End Sub

this would do it
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,173
Members
453,021
Latest member
Justyna P

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