VBA compile error

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"
 
P

Per Jessen

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top