Hi,
I've created a macro that searches and then auto populates a form based on customer details. It then keeps a record of customer contacts made by sales reps. I am now trying to add the functionality to produce a weekly report of activity by reps.
Each customers records are stored on its own worksheet, which is named as the respective customer number. I need the macro to loop through all of the customers worksheets and copy any active cells from B5 and down and to the right. If no cells are present I want to skip that customers worksheet and move on to the next one. Sheets that will not be included in this loop include: "Menu", "CustomerDetails", "Account", "Name", "Reference", "ReasonForCall" and "Temporary".
The information being copied from the customers worksheet to the summary will be contained in columns B:F, the date of the contact is contained in column B. I am hoping to filter the results contained in the summary by date, possibly using a MsgBox that allows you to select the chosen values.
I will also need a reference of the account number for each customer contact contained in the summary (which will be the name of the worksheet that the information is copied from). The summary will be compiled on worksheet "WeeklySummary", with the first entry starting on the 3rd row.
I've had a go with the coding below but it's all got a bit too complicated for my basic knowledge, any help would be much appreciated.
I've created a macro that searches and then auto populates a form based on customer details. It then keeps a record of customer contacts made by sales reps. I am now trying to add the functionality to produce a weekly report of activity by reps.
Each customers records are stored on its own worksheet, which is named as the respective customer number. I need the macro to loop through all of the customers worksheets and copy any active cells from B5 and down and to the right. If no cells are present I want to skip that customers worksheet and move on to the next one. Sheets that will not be included in this loop include: "Menu", "CustomerDetails", "Account", "Name", "Reference", "ReasonForCall" and "Temporary".
The information being copied from the customers worksheet to the summary will be contained in columns B:F, the date of the contact is contained in column B. I am hoping to filter the results contained in the summary by date, possibly using a MsgBox that allows you to select the chosen values.
I will also need a reference of the account number for each customer contact contained in the summary (which will be the name of the worksheet that the information is copied from). The summary will be compiled on worksheet "WeeklySummary", with the first entry starting on the 3rd row.
I've had a go with the coding below but it's all got a bit too complicated for my basic knowledge, any help would be much appreciated.
Code:
Sub WeeklySummary()
Dim SH As Worksheet
Dim rng As Range
Dim rCell As Range
Dim iCol As Long
Dim iRow As Long
Set rng = ActiveWorkbook.Sheets("CustomerDetails").Range("AccountList")
For Each SH In ActiveWorkbook.Worksheets
If Not IsError(Application.Match(SH.Name, rng, 0)) Then
End If
iMaxRow = 1000
For iCol = 2 To 6
For iRow = 5 To iMaxRow
With Worksheets(SH).Cells(iRow, iCol)
If .Value = "" Then
Else
.Copy Destination:=Worksheets("WeeklySummary").Cells(iRow, iCol)
End If
End With
Next iRow
Next iCol
Next SH
End Sub