Hi guys :
I've been working on a requirement that involves, collating data from multiple sales reps and consolidating them into one file. Once this collation is done, we would be using this worksheet to generate reports . This is required on a monthly basis
I managed to find some code on the web , that helps me collate the data, but need help in these two aspects :
1) I'm able to collate the data from multiple sheets (it is appended in the same worksheet), but i loose the header in the master sheet. The header will be in the same lines as
Sl No Sales Rep Customer Product Month Unit Price Qty
How can i ensure that the master has this header and the collation of data starts after their headers.
2) On running of the macro, all files open up and remains open after the data is collected on the master. How can i close the sheets after the master has been populated with data.
3) Since the data is collected from multiple sheets, each users data have their line items numbered, but in the master sheet, we find that the numbering (Sl no) is not consistnt. How can i have a sequential numbering in column A for all data.
Would appreciate any inputs , pointers in this regard...
TIA.
Sushesh
The code that i use is :
Sub Get_Value_From_All()
Dim wbSource As Workbook
Dim wbThis As Workbook
Dim rToCopy As Range
Dim uRng As Range
Dim rNextCl As Range
Dim lCount As Long
With Application
.ScreenUpdating = False
.DisplayAlerts = False
.EnableEvents = False
On Error Resume Next
Set wbThis = ThisWorkbook
'clear the range except headers
Set uRng = wbThis.Worksheets(1).UsedRange
uRng.Offset(1, 0).Resize(uRng.Rows.Count - 1, _
uRng.Columns.Count).Clear
With .FileSearch
.NewSearch
'Change path to suit
.LookIn = "C:\Test"
.FileType = msoFileTypeExcelWorkbooks
If .Execute > 0 Then 'Workbooks in folder
For lCount = 1 To .FoundFiles.Count ' Loop through all.
'Open Workbook x and Set a Workbook variable to it
Set wbSource = Workbooks.Open(Filename:=.FoundFiles(lCount), UpdateLinks:=0)
Set rToCopy = wbSource.Worksheets(1).UsedRange
Set rNextCl = wbThis.Worksheets(1).Cells(Rows.Count, 1).End(xlUp).Offset(2, 0)
rToCopy.Offset(1, 0).Resize(rToCopy.Rows.Count - 1, _
rToCopy.Columns.Count).Copy rNextCl
Next lCount
Else: MsgBox "No workbooks found"
End If
End With
On Error GoTo 0
.ScreenUpdating = True
.DisplayAlerts = True
.EnableEvents = True
End With
End Sub
Bookmarks