ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Define variable from cell to open a file (https://www.excelbanter.com/excel-programming/395661-re-define-variable-cell-open-file.html)

Jim Thomlinson

Define variable from cell to open a file
 
Try this...

Dim strFileName as String
strFileName = Range("B1").Value
Workbooks.Open Filename:="V:\FTP Data\" & strFileName

Note - Don't declare a variable FileName as that is a reserved word(ish).
--
HTH...

Jim Thomlinson


"Amir" wrote:

I have it calling B1

"Amir" wrote:

I am trying to open a file that has a date in its name. EX Data-20070816.csv

I have the user input the date in one cell (a1) and have a string formula in
another cell (b1).

I keep getting an error when I try to define the variable.


Windows("Data Comparison.xls").Activate
Application.Run "BLPLinkReset"
Sheets("Sheet1").Select

Dim Filename As String
Set Filename = Range("B1").Select

Workbooks.Open Filename:="V:\FTP Data\(Filename)"



All times are GMT +1. The time now is 07:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com