![]() |
go to the same path of the excel file being launched
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 |
more explanation
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 doesnt work and i need your help to fix it. Tim "Tim" wrote: 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 |
more explanation
Try something like:
..Formula = "=" & ThisWorkbook.Path & "\test\[Book1.xls]Sheet1'!A1" "Tim" wrote in message ... 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" wrote: 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 |
All times are GMT +1. The time now is 01:16 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com