Plastik808
New Member
- Joined
- Aug 15, 2011
- Messages
- 11
Hello,
I have a folder, containing 120 workbooks(which only contain 1 sheet each). Each workbook represents a traders PnL for the year so there are 10 traders.
I need to find a way of writing some code that will look into each workbook and grab the total at the bottom (which has traders name attached) and placing this in a seperate workbook. The code i have below works if all the traders PnL are contained with the same workbook, so im asking how can i modify this to look at all workbooks contained in a folder?
Dim employee As String, total As Integer, sheet As Worksheet, i As Integer
total = 0
employee = InputBox("Enter the employee name (case sensitive)")
For Each sheet In Worksheets
For i = 2 To 13
If sheet.Cells(i, 2).Value = employee Then
total = total + sheet.Cells(i, 3).Value
End If
Next i
Next sheet
MsgBox "Total sales of " & employee & " is " & total
End Sub
many thanks in advance!
I have a folder, containing 120 workbooks(which only contain 1 sheet each). Each workbook represents a traders PnL for the year so there are 10 traders.
I need to find a way of writing some code that will look into each workbook and grab the total at the bottom (which has traders name attached) and placing this in a seperate workbook. The code i have below works if all the traders PnL are contained with the same workbook, so im asking how can i modify this to look at all workbooks contained in a folder?
Dim employee As String, total As Integer, sheet As Worksheet, i As Integer
total = 0
employee = InputBox("Enter the employee name (case sensitive)")
For Each sheet In Worksheets
For i = 2 To 13
If sheet.Cells(i, 2).Value = employee Then
total = total + sheet.Cells(i, 3).Value
End If
Next i
Next sheet
MsgBox "Total sales of " & employee & " is " & total
End Sub
many thanks in advance!