go to the same path of the excel file being launched

G

Guest

Hi All,
This macro:

Sub GetData()
With Range("F1:F10")
.Formula = "='C:\Documents and
Settings\Tim\Desktop\test\[Book1.xls]Sheet1'!A1"
.Formula = .Value
End With
End Sub

works fine but i need to change the line:

..Formula = "='C:\Documents and
Settings\Tim\Desktop\test\[Book1.xls]Sheet1'!A1"

Instead to go to that directory above, to go to the folder test which is in
the same path of the excel file being launched.
Something like this:
..Formula =ThisWorkbook.Path & "\test\Book1.xls"

Any Help is highly appreciated.

Tim
 
G

Guest

In my previous posting i mean i need to change the
line:
..Formula = "='C:\Documents and
Settings\Tim\Desktop\test\[Book1.xls]Sheet1'!A1"

to something like this:
..Formula =ThisWorkbook.Path & "\test\[Book1.xls]Sheet1'!A1"

As you can guess the second line is only guided. It doesn’t work and i need
your help to fix it.

Tim
 
V

Vasant Nanavati

Try something like:

..Formula = "=" & ThisWorkbook.Path & "\test\[Book1.xls]Sheet1'!A1"



Tim said:
In my previous posting i mean i need to change the
line:
.Formula = "='C:\Documents and
Settings\Tim\Desktop\test\[Book1.xls]Sheet1'!A1"

to something like this:
.Formula =ThisWorkbook.Path & "\test\[Book1.xls]Sheet1'!A1"

As you can guess the second line is only guided. It doesn't work and i
need
your help to fix it.

Tim


Tim said:
Hi All,
This macro:

Sub GetData()
With Range("F1:F10")
.Formula = "='C:\Documents and
Settings\Tim\Desktop\test\[Book1.xls]Sheet1'!A1"
.Formula = .Value
End With
End Sub

works fine but i need to change the line:

.Formula = "='C:\Documents and
Settings\Tim\Desktop\test\[Book1.xls]Sheet1'!A1"

Instead to go to that directory above, to go to the folder test which is
in
the same path of the excel file being launched.
Something like this:
.Formula =ThisWorkbook.Path & "\test\Book1.xls"

Any Help is highly appreciated.

Tim
 

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