I am trying to extract information from a closed workbook using excel VBA, more specifically, the sum of a range of numbers in the closed excel workbook into my current excel workbook.
I have tried the following codes below:
I want to find the sum of values from Z8 to the last Z cell in the column.
Range("D4").Formula = "Sum('I:\Outgoing\Money Outgoing\'!$Z8:$Z)"
Set wkbk = Workbooks.Open("I:\Outgoing\Money Outgoing.xlsx\")
Range("Z7").Select
ActiveCell.FormulaR1C1 = "=SUM(Z8:Z10000)"
Range("D4").Value = GetInfoFromClosedFile(a, f, d, "Z6")
I do not wish to open the closed workbook The excel file is Money Outgoing.xlsx There is only 1 tab in the file. Tab name is Layout 1
I:
a mapped network drive? What if someone renames itMoney Outgoing 2019-2020.xlsx
? You could probably trySheet1.Range("D4").Formula = "=Sum('[I:\Outgoing\Money Outgoing.xlsx]Layout 1'!$Z8:$Z10000)"
. See avoid Select and Activate, too. Good luck! – Mathieu Guindon$Z8:$Z
is a syntax error as far as Excel is concerned. – Mathieu Guindon