Dovile L.
Dovile L.

Reputation: 17

How to open another excel using VBA

I have tried to write a script to open another excel.

My code

Sub test()
filetoopen=thisworkbook.worksheet("sheet1").Range("D18")

Where is my mistake?

Thank you for your advice.

Upvotes: 1

Views: 78

Answers (1)

Jonas Palačionis
Jonas Palačionis

Reputation: 4842

You can use:

Sub test()
filetoopen = ThisWorkbook.Worksheets("sheet1").Range("D18")
Workbooks.Open FileName:=filetoopen
ActiveWindow.ActivatePrevious

Upvotes: 2

Related Questions