VBA Macro Creating Report

Cugedhion

New Member
Joined
Nov 19, 2014
Messages
14
Hi,

I have this data
Sheet 2
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Name[/TD]
[TD]Date[/TD]
[TD]Working Hours[/TD]
[TD]Task[/TD]
[TD]Status[/TD]
[TD]AND SO ON...[/TD]
[/TR]
[TR]
[TD]Sam[/TD]
[TD]01/01/2015[/TD]
[TD]9.00[/TD]
[TD]Help Pat[/TD]
[TD]OK[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Sam[/TD]
[TD]01/02/2015[/TD]
[TD]9.00[/TD]
[TD]Cook[/TD]
[TD]OK[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Sam[/TD]
[TD]01/03/2015[/TD]
[TD]9.00[/TD]
[TD]Walking[/TD]
[TD]PENDING[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Sam[/TD]
[TD]01/04/2015[/TD]
[TD]9.00[/TD]
[TD]Watch TV[/TD]
[TD]OK[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]PAT[/TD]
[TD]01/01/2015[/TD]
[TD]2.00[/TD]
[TD]Study[/TD]
[TD]OK[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]PAT[/TD]
[TD]01/02/2015[/TD]
[TD]2.00[/TD]
[TD]Clean[/TD]
[TD]OK[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]PAT[/TD]
[TD]01/03/2015[/TD]
[TD]1.00[/TD]
[TD]Read[/TD]
[TD]OK[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]PAT[/TD]
[TD]01/04/2015[/TD]
[TD]9.00[/TD]
[TD]Help Mom[/TD]
[TD]OK[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]BEA[/TD]
[TD]01/01/2015[/TD]
[TD]1.00[/TD]
[TD]Do Homework[/TD]
[TD]OK[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]BEA[/TD]
[TD]01/02/2015[/TD]
[TD]2.00[/TD]
[TD]Help Dad[/TD]
[TD]OK[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]BEA[/TD]
[TD]01/03/2015[/TD]
[TD]2.00[/TD]
[TD]Drive[/TD]
[TD]OK[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]BEA[/TD]
[TD]01/04/2015[/TD]
[TD]8.00[/TD]
[TD]Watch Movie[/TD]
[TD]PENDING[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]AND SO ON...[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


And I want to do it this way.

Report
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Name[/TD]
[TD]01/01/2015[/TD]
[TD]01/02/2015[/TD]
[TD]01/03/2015[/TD]
[TD]01/04/2015[/TD]
[TD]AND SO ON...[/TD]
[/TR]
[TR]
[TD]Sam[/TD]
[TD]9.00[/TD]
[TD]9.00[/TD]
[TD]9.00[/TD]
[TD]9.00[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Pat[/TD]
[TD]2.00[/TD]
[TD]2.00[/TD]
[TD]1.00[/TD]
[TD]9.00[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Bea[/TD]
[TD]1.00[/TD]
[TD]2.00[/TD]
[TD]2.00[/TD]
[TD]8.00[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]AND SO ON...[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

========================================================

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Sam[/TD]
[TD][/TD]
[TD]Pat[/TD]
[TD][/TD]
[TD]Bea[/TD]
[TD][/TD]
[TD]AND SO ON...[/TD]
[/TR]
[TR]
[TD]Help Pat[/TD]
[TD]9.00[/TD]
[TD]Study[/TD]
[TD]2.00[/TD]
[TD]Do Homework[/TD]
[TD]1.00[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Cook[/TD]
[TD]9.00[/TD]
[TD]Clean[/TD]
[TD]2.00[/TD]
[TD]Help Dad[/TD]
[TD]2.00[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Walking[/TD]
[TD]9.00[/TD]
[TD]Read[/TD]
[TD]1.00[/TD]
[TD]Drive[/TD]
[TD]2.00[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Watch TV[/TD]
[TD]9.00[/TD]
[TD]Help Mom[/TD]
[TD]9.00[/TD]
[TD]Watch Movie[/TD]
[TD]8.00[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]AND SO ON....[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


I have my code here, And I got stuck I don't know what comes next after this code. Is there any clean and neat way to come up with this output?


Code:
Worksheets("Report").Select
Sheets("Sheet2").Columns(12).Copy Destination:=Sheets("Report").Columns(1)
Range("A:A").RemoveDuplicates Columns:=1, Header:=xlYes
NameRow = Range("A" & Rows.Count).End(xlUp).Row


Sheets("Sheet2").Columns(2).Copy Destination:=Sheets("Report").Columns(2)
Range("B:B").RemoveDuplicates Columns:=1, Header:=xlNo
DateRow = Range("B" & Rows.Count).End(xlUp).Row


Worksheets("Report").Range("B:B").Sort _
Key1:=Range("B1"), _
Order1:=xlAscending, _
Header:=xlYes


Dim ResDate() As String
Dim I As Integer
ReDim ResDate(2 To DateRow)


    For I = 2 To DateRow
        ResDate(I) = Format(Cells(I, 2), "mm-dd-yyyy")
        Cells(I, 2) = ""
        Cells(1, I) = ResDate(I)
    Next


Dim ResName() As String
Dim K As Integer
ReDim ResName(2 To NameRow)


    For K = 2 To NameRow
        ResName(K) = Cells(K, 1)
    Next

Please Help Me :(
 
Last edited:

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