Hi Pawan
The below macro would generate the unique list as a new sheet in your active
workbook. The macro would get data from all sheets of all workbooks present
in the folder. Launch VBE by hitting Alt+F11. From menu 'Insert' a module and
paste the below code. Get back to Workbook and run macro from Tools|Macro|Run
<selected macro()>. Please note that there is a subprocedure. Try and
feedback..
Sub GenerateUniqueList()
Dim strFolder As String, strFile As String, ws As Worksheet
'Browse folder
With Application.FileDialog(msoFileDialogFolderPicker)
If .Show = False Then MsgBox ("No folder selected"): End
strFolder = .SelectedItems(1) & "\"
End With
Set ws = ActiveWorkbook.Worksheets.Add(After:=ActiveSheet)
'Browse all files within the folder
Application.ScreenUpdating = False: Application.DisplayAlerts = False
strFile = Dir(strFolder & "*.xl*", vbNormal)
Do While strFile <> ""
OpenAndGetData strFolder & strFile, ws
strFile = Dir
Loop
'Generate unique list
ws.Range("A1") = "Unique List"
ws.Columns(1).Sort Key1:=ws.Range("A2"), Order1:=xlAscending, _
Header:=xlYes, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
ws.Columns(1).AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=ws.Range("B1"), Unique:=True
Columns(1).Delete
Application.ScreenUpdating = True: Application.DisplayAlerts = True
MsgBox "Unique list generated"
End Sub
Sub OpenAndGetData(strWBook As String, ws As Worksheet)
Dim wbTemp As Workbook, wsTemp As Worksheet, lngRow As Long
Set wbTemp = Workbooks.Open(strWBook, ReadOnly:=True)
For Each wsTemp In wbTemp.Sheets
lngRow = ws.Cells(Rows.Count, "A").End(xlUp).Row
wsTemp.Range("A1:A" & wsTemp.Cells(Rows.Count, _
"A").End(xlUp).Row).Copy ws.Range("A" & lngRow + 1)
Next
wbTemp.Close False
End Sub
If this post helps click Yes