Try this code. Let me know how it works. Modifiy the two Const to define
your source and destination worksheet. I first put the data in the
destination sheet and then run a sort on the sheet.
Sub getresouses()
Const SourceSheet = "Sheet1"
Const DestSheet = "Sheet2"
With Worksheets(DestSheet)
LastrowDest = .Cells(Rows.Count, "A").End(xlUp).Row
End With
NewRowDest = LastrowDest + 1
With Worksheets(SourceSheet)
Lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
LastCol = .Cells(1, Columns.Count).End(xlToLeft).Column
For RowCount = 2 To Lastrow
For Colcount = 2 To LastCol Step 2
If Not IsEmpty(.Cells(RowCount, Colcount).Value) Then
Resource = .Cells(RowCount, Colcount).Value
PercentHours = .Cells(RowCount, Colcount). _
Offset(0, 1).Value
Project = .Cells(RowCount, "A").Value
hours = 0.4 * PercentHours
HourString = hours & " hrs (" & PercentHours & "% of 40)"
With Worksheets(DestSheet)
.Cells(NewRowDest, "A").Value = Resource
.Cells(NewRowDest, "B").Value = Project
.Cells(NewRowDest, "C").Value = HourString
End With
NewRowDest = NewRowDest + 1
End If
Next Colcount
Next RowCount
End With
With Worksheets(DestSheet)
Range("A2:C" & (NewRowDest - 1)).Sort _
Key1:=Range("A2"), _
Order1:=xlAscending, _
Key2:=Range("B2"), _
Order2:=xlAscending, _
Header:=xlGuess
End With
End Sub
> Hi Joel,
>
[quoted text clipped - 79 lines]
> > >
> > > Thanks!!
Joel - 19 Sep 2007 17:38 GMT
I left off a period on one statement
from
Range("A2:C" & (NewRowDest - 1)).Sort _
Key1:=Range("A2"), _
Order1:=xlAscending, _
Key2:=Range("B2"), _
Order2:=xlAscending, _
Header:=xlGuess
to
.Range("A2:C" & (NewRowDest - 1)).Sort _
Key1:=Range("A2"), _
Order1:=xlAscending, _
Key2:=Range("B2"), _
Order2:=xlAscending, _
Header:=xlGuess
> Try this code. Let me know how it works. Modifiy the two Const to define
> your source and destination worksheet. I first put the data in the
[quoted text clipped - 128 lines]
> > > >
> > > > Thanks!!
Joel - 19 Sep 2007 17:40 GMT
There need to be 3 periods in this statement
from:
Range("A2:C" & (NewRowDest - 1)).Sort _
Key1:=Range("A2"), _
Order1:=xlAscending, _
Key2:=Range("B2"), _
Order2:=xlAscending, _
Header:=xlGuess
to:
.Range("A2:C" & (NewRowDest - 1)).Sort _
Key1:=.Range("A2"), _
Order1:=xlAscending, _
Key2:=.Range("B2"), _
Order2:=xlAscending, _
Header:=xlGuess
> Try this code. Let me know how it works. Modifiy the two Const to define
> your source and destination worksheet. I first put the data in the
[quoted text clipped - 128 lines]
> > > >
> > > > Thanks!!