VBA compile error

  • Thread starter Thread starter Ed Davis
  • Start date Start date
E

Ed Davis

The first line of code below works fine.
I am trying to get the second one to work instead as I want to open the
workbook that has the name from a date in cell B1.
I get the following error.
Invalid or Object or unqualified reference

It stops at (.Worksheets("01")

Workbooks.Open Filename:="C:\Posto Pote\August Gasolina.xls"

Workbooks.Open Filename:="C:\Posto Pote\" &
Format(.Worksheets("01").Range("B1").Value, "mmmm ") & "Gasolina.xls"
 
Hi Ed.

What is the dot refering to?
It stops at (.Worksheets("01")

If you don't have a With statement setting a reference for a workbook, I guess you just have to remove the dot.

Hopes this helps.
....
Per
 
Back
Top