I need to adapt this code by add sheet name in D4 . the stock file will be many sheets and the last value will be in column H for all of sheets. if I write the sheet name in D4 then should get last value from column H based on matching with sheet name.
thanks
VBA Code:
Sub populate_last_value()
Dim wb1 As Workbook, wb2 As Workbook
Dim sPath As String
sPath = "D:\Users\MUSSS\Desktop\REPORT\"
Set wb1 = Workbooks.Open(sPath & "OUTPUT.xlsm")
Set wb2 = Workbooks.Open(sPath & "STOCK.xlsm")
wb1.Sheets("SUMMARY").Range("B4").Value = wb2.Sheets("SH").Range("H" & Rows.Count).End(3).Value
wb2.Close TRUE
End Sub