excel_noob86
New Member
- Joined
- Nov 10, 2009
- Messages
- 30
Hi,
I have an employee sheet which has multiple hours rows for one employee, i want to select an employee ID and add corresponding hours and place both in a separate sheet. Here's my code so far.
Iam getting an error 1004 at
Can anybody help me please?? Thanks in advance
I have an employee sheet which has multiple hours rows for one employee, i want to select an employee ID and add corresponding hours and place both in a separate sheet. Here's my code so far.
Code:
Sub dup()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Set NewSheet = Worksheets.Add
NewSheet.Name = "NEW"
Set NewSheet = Worksheets.Add
supcount = 2
countresources = 0
Do While Sheets("RS Nov 2009").Range("A" & supcount).Value <> ""
countresources = countresources + 1
supcount = supcount + 1
Loop
'Dim temp As Range
Dim i, j, hours As Integer
hours = 0
Sheets("RS Nov 2009").Select
Columns("A:A").Select
Selection.Copy
Columns("Q:Q").Select
Selection.Copy
For i = 0 To supcount
For j = i + 1 To supcount
If Sheets("RS Nov 2009").Range("A" & i).Value = Sheets("RS Nov 2009").Range("A" & j).Value Then
hours = hours + Sheets("RS Nov 2009").Range("Q" & j).Value
Sheets("NEW").Range("A" & i).Value = Sheets("RS Nov 2009").Range("A" & i).Value
Sheets("NEW").Range("B" & i).Value = hours
End If
Next
Next
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub
Iam getting an error 1004 at
Code:
If Sheets("RS Nov 2009").Range("A" & i).Value = Sheets("RS Nov 2009").Range("A" & j).Value Then
Can anybody help me please?? Thanks in advance