Here is the codes...
Dim Ftwbook As Workbook
Dim Thiswbook As Workbook
Dim LastPM, LastCell, RIndex, counter As Integer
Dim Wksheet As Worksheet
Dim Flatfilename As String
Dim Filewithmacro As String
Application.ScreenUpdating = False
Flatfilename = Application.GetOpenFilename(FileFilter:="Excel files (*.xls), *.xls", Title:="Please choose a file")
Filewithmacro = ThisWorkbook.Name
Set Ftwbook = Workbooks.Open(Filename:=Flatfilename, ReadOnly:=yes)
Set Thiswbook = Workbooks(Filewithmacro)
ThisWorkbook.Worksheets("Project Managers").Activate
Range("A1").Select
LastCell = ActiveCell.SpecialCells(xlCellTypeLastCell).Row
ReDim PM(LastCell) As String
For counter = 0 To LastCell - 1
PM(counter) = ActiveCell.Value
ActiveCell.Offset(1, 0).Activate
Next counter
Thiswbook.Worksheets("Project List").Activate
Range("A4", Range("A4").SpecialCells(xlCellTypeLastCell).Address).Rows.ClearContents
Ftwbook.Activate
Ftwbook.Worksheets("Flat File").Select
Range("Y4").Select
LastPM = ActiveCell.SpecialCells(xlCellTypeLastCell).Row
RIndex = 4
For counter = 0 To LastPM - 1
For Index = 0 To LastCell - 1
If ActiveCell.Value = PM(Index) Then
ActiveCell.EntireRow.Copy
Thiswbook.Worksheets("Project List").Activate
ActiveSheet.Paste Destination:=Range(Cells(RIndex, 1), Cells(RIndex, 1))
Ftwbook.Worksheets("Flat File").Activate
RIndex = RIndex + 1
Exit For
Else
End If
Next Index
ActiveCell.Offset(1, 0).Activate
Next counter
Application.CutCopyMode = False
Ftwbook.Close SaveChanges = no
Application.ScreenUpdating = True
Call LastRowofPM
End Sub
----------------------
Pls help me in this....