Dear All,
The code I have below, extracts data from a closed file within a specific folder.
For every file I want to extract data, I have to edit the code within the module.
What I will like to do is to reference this part of my code to a cell say "A1".
This is where my code has
The below is my code:
Sub ConsolFiles()
Dim wsMaster As Worksheet
Set wsMaster = Worksheets("Mastersheet")
Dim nextrow As Long
Dim Files(1 To 1) As String
' This part needs to reference to a fixed cell within the Master sheet.
Files(1) = "temp2"
Dim filepath As String
‘Filepath goes into below
filepath = "C:\Documents …………."
Dim filenum As Integer
Application.ScreenUpdating = False
With wsMaster
.Cells.Clear
End With
For filenum = 1 To 1
nextrow = wsMaster.UsedRange.Rows.Count + wsMaster.UsedRange.Row
Workbooks.Open (filepath & Files(filenum))
Worksheets("Accident Book").Range("A6:N" & Range("A" & Rows.Count).End(xlUp).Row).Copy _
wsMaster.Cells(nextrow, 1)
Next
ThisWorkbook.Activate
Call CloseAll
Application.ScreenUpdating = True
End Sub
Kind Regards
Laylow
Bookmarks