0

I am trying to access cell F7 of all workbooks which are contained in the folder "CustomerFolder". The catch is that I do not know the names of the workbooks which are in the folder "CustomerFolder".

Normally you would use

 Application.Goto Workbooks("CustomerFolder/Customer1.XLS").Sheets("Sheet1").Range("F7")

to access cell F7 in the workbook "Customer1.XLS".

However, I do not know the names of the workbooks that I am trying to access beforehand.

I am completely new to VBA and I am wondering how to solve this problem? Or whether this is even possible.

Mathieu Guindon
  • 69,817
  • 8
  • 107
  • 235
Balraj Boyal
  • 155
  • 1
  • 2
  • 13
  • You'd use the `FileSystem` object to get all the XL files in the folder, open each file, check `Sheet 1` exists and select the cell. Can't imagine why you'd want to though - what are you going to do with the contents once you've selected them? And do you _really_ need to select the cell first? – Darren Bartrup-Cook Sep 04 '18 at 13:55
  • I am making a bookkeeping program which allows me to create a financial balance. Every workbook contains the financial details of a customer and I am trying to make a main workbook which shows the summary of every customer in a nice overview. – Balraj Boyal Sep 04 '18 at 14:01
  • 1
    This [link](https://stackoverflow.com/questions/31414106/get-list-of-excel-files-in-a-folder-using-vba) will tell you how to get the files in the folder and then something like `MyVariable = ExecuteExcel4Macro("'C:\FilePath\[FileName.xlsx]SheetName'!R7C6")` to pull info from F7 of the closed workbook - `R7C6` is **R**ow 7, **C**olumn 6 (F7). – Darren Bartrup-Cook Sep 04 '18 at 14:24

0 Answers0