VBA Macro Creating Report

Cugedhion

New Member
Joined
Nov 19, 2014
Messages
14
Hi,

I have this data
Sheet 2
NameDateWorking HoursTaskStatusAND SO ON...
Sam01/01/20159.00Help PatOK
Sam01/02/20159.00CookOK
Sam01/03/20159.00WalkingPENDING
Sam01/04/20159.00Watch TVOK
PAT01/01/20152.00StudyOK
PAT01/02/20152.00CleanOK
PAT01/03/20151.00ReadOK
PAT01/04/20159.00Help MomOK
BEA01/01/20151.00Do HomeworkOK
BEA01/02/20152.00Help DadOK
BEA01/03/20152.00DriveOK
BEA01/04/20158.00Watch MoviePENDING
AND SO ON...

<tbody>
</tbody>


And I want to do it this way.

Report
Name01/01/201501/02/201501/03/201501/04/2015AND SO ON...
Sam9.009.009.009.00
Pat2.002.001.009.00
Bea1.002.002.008.00
AND SO ON...

<tbody>
</tbody>

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

SamPatBeaAND SO ON...
Help Pat9.00Study2.00Do Homework1.00
Cook9.00Clean2.00Help Dad2.00
Walking9.00Read1.00Drive2.00
Watch TV9.00Help Mom9.00Watch Movie8.00
AND SO ON....

<tbody>
</tbody>


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:

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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