Hi,
Im currently using this code
Sub CopyDishonours_Click()
Dim vFile As Variant
Dim wbCopyTo As Workbook
Dim wsCopyTo As Worksheet
Dim wbCopyFrom As Workbook
Dim wsCopyFrom As Worksheet
Dim Last_Row As Long
Dim cLast_Row As Long
Dim wb1 As Workbook
Set wbCopyTo = ActiveWorkbook
Set wb1 = ThisWorkbook
Set wsCopyTo = wb1.Sheets("Data")
'-------------------------------------------------------------
'Open file with data to be copied
vFile = Application.GetOpenFilename("Excel Files (*.xl*)," & _
"*.xl*", 1, "Select Excel File", "Open", False)
'If Cancel then Exit
If TypeName(vFile) = "Boolean" Then
Exit Sub
Else
Set wbCopyFrom = Workbooks.Open(vFile)
Set wsCopyFrom = wbCopyFrom.Worksheets(1)
End If
'--------------------------------------------------------------
'Copy Range
Application.DisplayAlerts = False
Last_Row = Range("P" & Rows.Count).End(xlUp).Row
cLast_Row = wb1.Sheets("Data").Range("A2" & Rows.Count).End(xlUp).Row
wsCopyFrom.Range("P12:B" & Last_Row).SpecialCells(xlCellTypeVisible).Copy
wsCopyTo.Activate
Range("A1").Offset(cLast_Row, 0).Select
Selection.PasteSpecial xlPasteValues
'Close file that was opened
Application.DisplayAlerts = False
wbCopyFrom.Close SaveChanges:=False
End Sub
I would like to know how I can a folder and loop the code above through all the files in the chosen folder.
Bookmarks