I have a worksheet for every Month from Jan to Dec and a worksheet called Report where the copied data goes
In the Months sheet I have the following Data
ID NAME # DAYS OF VACATION
1 GEORGE 3
2 MARY 5
Every Month sheet has the same names but the names are not bound to the same ID What i want to do in Summary sheet is
ID NAME # DAYS OF VACATION MONTH
1 GEORGE 3 JAN
2 GEORGE 2 FEB
SUM GEORGE 5 YEAR
What I have managed to do is to copy from one Month sheet to Report but I can't copy multiple from all the Month sheets and I don't know how to do the SUM part. Any ideas?
Sub SearchForString()
Dim LSearchRow As Integer
Dim LCopyToRow As Integer
On Error GoTo Err_Execute
'Start search in row 2
LSearchRow = 2
'Start copying data to row 2 in Sheet2 (row counter variable)
LCopyToRow = 2
fname = InputBox("Enter Name", "Enter Data")
If fname = "" Then
While fname = ""
MsgBox ("Enter Name")
fname = InputBox("Enter Name", "Enter Data")
Wend
End If
While Len(Range("A" & CStr(LSearchRow)).Value) > 0
'If value in column E = "Mail Box", copy entire row to Sheet2
If Sheets("JAN").Range("B" & CStr(LSearchRow)).Value = fname Then
'Select row in Sheet1 to copy
Rows(CStr(LSearchRow) & ":" & CStr(LSearchRow)).Select
Selection.Copy
'Paste row into Sheet2 in next row
Sheets("REPORT").Select
Rows(CStr(LCopyToRow) & ":" & CStr(LCopyToRow)).Select
ActiveSheet.Paste
'AddWatermark ("JAN")
'Move counter to next row
LCopyToRow = LCopyToRow + 1
End If
'Go back to Sheet1 to continue searching
Sheets("REPORT").Select
LSearchRow = LSearchRow + 1
Wend
'Position on cell A3
Application.CutCopyMode = False
Range("A3").Select
MsgBox "COPY DONE"
Exit Sub
Err_Execute:
MsgBox "ERROR"
End Sub