PC Review


Reply
Thread Tools Rate Thread

Define variable from cell to open a file

 
 
=?Utf-8?B?QW1pcg==?=
Guest
Posts: n/a
 
      17th Aug 2007
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("A1").Select

Workbooks.Open Filename:="V:\FTP Data\(Filename)"
 
Reply With Quote
 
 
 
 
=?Utf-8?B?QW1pcg==?=
Guest
Posts: n/a
 
      17th Aug 2007
Yes the file exists. I have strFilename1X.

"Jim Thomlinson" wrote:

> Where does the 1X come from. By prefixing FileName with "str" we get aound
> the reserved word issue.
>
> Does a file exist such as
> V:\FTP Data\Data-20070816.csv
>
> --
> HTH...
>
> Jim Thomlinson
>
>
> "Amir" wrote:
>
> > It errors out at the Filename:="V:\FTP Date\" & strFileName1X
> >
> >
> >
> > "Jim Thomlinson" wrote:
> >
> > > 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)"

 
Reply With Quote
 
=?Utf-8?B?SmltIFRob21saW5zb24=?=
Guest
Posts: n/a
 
      17th Aug 2007
Where does the 1X come from. By prefixing FileName with "str" we get aound
the reserved word issue.

Does a file exist such as
V:\FTP Data\Data-20070816.csv

--
HTH...

Jim Thomlinson


"Amir" wrote:

> It errors out at the Filename:="V:\FTP Date\" & strFileName1X
>
>
>
> "Jim Thomlinson" wrote:
>
> > 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)"

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Define variable from cell to open a file =?Utf-8?B?QW1pcg==?= Microsoft Excel Programming 2 17th Aug 2007 01:51 AM
RE: Define variable from cell to open a file =?Utf-8?B?SmltIFRob21saW5zb24=?= Microsoft Excel Programming 0 17th Aug 2007 01:45 AM
Why can'y I open a .txt file and define the columns? =?Utf-8?B?VHJhY3kyMTI=?= Microsoft Excel Crashes 1 3rd Apr 2005 10:08 AM
Define the appearance of cell in a CSS file =?Utf-8?B?SmVmZg==?= Microsoft Frontpage 2 20th Jun 2004 11:17 AM
Syntax to define a variable for current file Mervyn Thomas Microsoft Excel Programming 2 22nd Dec 2003 06:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:01 PM.