PC Review


Reply
Thread Tools Rate Thread

Cell reference to determine filename

 
 
cangiff
Guest
Posts: n/a
 
      5th Jun 2009
I am trying to write a macro that saves a current file to a new file.

in the VBA line: ActiveWorkbook.SaveAs Filename =

I want to add a reference to the cell that contains the required filename. I
have therefore tried adding the following:

ActiveWorkbook.SaveAs Filename = "=' [macro test.xls] Sheet 1' !R10C3"

This address contains the desired filename. However when I run the macro it
fails as "the file could not be accessed......."

I suspect my programmming is flawed. Can you help?

Actiallows me to put the required filename that I wish to save to in as a
--
cangiff
 
Reply With Quote
 
 
 
 
cangiff
Guest
Posts: n/a
 
      5th Jun 2009
Thank you that works perfectly
--
cangiff


"Jacob Skaria" wrote:

> Try the below
>
> Dim strFile as String
> strFile = Workbooks("macro test.xls").Sheets("Sheet1").Range("C10")
>
> OR
> 'if this is the active workbook
> strFile = Sheets("Sheet1").Range("C10")
>
> ActiveWorkbook.SaveAs Filename:=strFile
> --
> If this post helps click Yes
> ---------------
> Jacob Skaria
>
>
> "cangiff" wrote:
>
> > I am trying to write a macro that saves a current file to a new file.
> >
> > in the VBA line: ActiveWorkbook.SaveAs Filename =
> >
> > I want to add a reference to the cell that contains the required filename. I
> > have therefore tried adding the following:
> >
> > ActiveWorkbook.SaveAs Filename = "=' [macro test.xls] Sheet 1' !R10C3"
> >
> > This address contains the desired filename. However when I run the macro it
> > fails as "the file could not be accessed......."
> >
> > I suspect my programmming is flawed. Can you help?
> >
> > Actiallows me to put the required filename that I wish to save to in as a
> > --
> > cangiff

 
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
RE: Cell reference to determine filename Jacob Skaria Microsoft Excel Programming 0 5th Jun 2009 03:05 PM
Cell reference to a filename Stevep4 Microsoft Excel Misc 10 14th Jan 2009 10:30 PM
Reference filename used in code from cell shamble@gmail.com Microsoft Excel Programming 5 15th Mar 2006 02:53 PM
substitute the filename in a cell reference with a string in another cell. flummi Microsoft Excel Misc 11 22nd Feb 2006 01:14 PM
Want to use Cell content as reference filename. =?Utf-8?B?Qmlt?= Microsoft Excel Worksheet Functions 2 20th Oct 2004 08:48 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:54 AM.