Hello All,
New to this forum and looking for some help. I have the need to copy the values from the same cell in multiple workbooks in the same folder into a master file. I have come up with some basic VBA code that will sum the values of the same cell over multiple files and place that total into a cell in my reports worksheet. I now need to take the values for Cell R153 from every file in a folder and sequentialy paste it into the master report.xlsm file to sheet 2 starting H2. I was hoping to modify the below code to achieve what i need.
Sub PROCESS_FILES()
Dim MyFolder As String
Dim MyFile As String
Dim MyValue As Single
'--------------------
MyValue = 0
MyFolder = "Z:\Billable Hours\Weekly Totals 2019"
MyFile = Dir(MyFolder & "*.XLSX")
Do While MyFile <> ""
Application.StatusBar = MyFile
Workbooks.Open Filename:=MyFolder & MyFile
MyValue = ActiveWorkbook.Sheets(1).Range("R149").Value
ActiveWorkbook.Close savechanges:=False
MyFile = Dir
Loop
ThisWorkbook.Sheets(2).Range("H2").Value = MyValue
MsgBox (MyValue)
Application.StatusBar = False
End Sub
New to this forum and looking for some help. I have the need to copy the values from the same cell in multiple workbooks in the same folder into a master file. I have come up with some basic VBA code that will sum the values of the same cell over multiple files and place that total into a cell in my reports worksheet. I now need to take the values for Cell R153 from every file in a folder and sequentialy paste it into the master report.xlsm file to sheet 2 starting H2. I was hoping to modify the below code to achieve what i need.
Sub PROCESS_FILES()
Dim MyFolder As String
Dim MyFile As String
Dim MyValue As Single
'--------------------
MyValue = 0
MyFolder = "Z:\Billable Hours\Weekly Totals 2019"
MyFile = Dir(MyFolder & "*.XLSX")
Do While MyFile <> ""
Application.StatusBar = MyFile
Workbooks.Open Filename:=MyFolder & MyFile
MyValue = ActiveWorkbook.Sheets(1).Range("R149").Value
ActiveWorkbook.Close savechanges:=False
MyFile = Dir
Loop
ThisWorkbook.Sheets(2).Range("H2").Value = MyValue
MsgBox (MyValue)
Application.StatusBar = False
End Sub