Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Using a cell reference in a filepath

Hello,

The following code saves the active workbook in c:/files

ActiveWorkbook.SaveAs "C:\files\" & ActiveWorkbook.Name

However, I have two sub folders in c:\files,

c:\files\new\ and c:\files\old\

Is it possible to add a cell reference to the end of

ActiveWorkbook.SaveAs "C:\files\"

so I can type, for example, "old" or "new" in cell A1, and when I save using
the above code, excel will save in the appropriate sub folder?

I have tried along the lines of:

ActiveWorkbook.SaveAs "C:\files\Range("A1")" & ActiveWorkbook.Name

but I cannot get it to work.

Thanks in advance.

Pinda.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Using a cell reference in a filepath

Close !

ActiveWorkbook.SaveAs "C:\files\Range" & Range("A1").Value &
ActiveWorkbook.Name


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Pinda" wrote in message
...
Hello,

The following code saves the active workbook in c:/files

ActiveWorkbook.SaveAs "C:\files\" & ActiveWorkbook.Name

However, I have two sub folders in c:\files,

c:\files\new\ and c:\files\old\

Is it possible to add a cell reference to the end of

ActiveWorkbook.SaveAs "C:\files\"

so I can type, for example, "old" or "new" in cell A1, and when I save

using
the above code, excel will save in the appropriate sub folder?

I have tried along the lines of:

ActiveWorkbook.SaveAs "C:\files\Range("A1")" & ActiveWorkbook.Name

but I cannot get it to work.

Thanks in advance.

Pinda.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Using a cell reference in a filepath

The code you entered was almost right, this should work

ActiveWorkbook.SaveAs "C:\files\" & Range("A1") & "\" &
ActiveWorkbook.Name

----
Sean
"Just press the off switch, and go to sleep!"

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Using a cell reference in a filepath

Bob,

Thanks again for the help, but the code you've given does not save the file
in the subfolder (old), it just adds "rangeold" to the front of the filename
and saves it in c:\files.


So if the file is called test.xls, it will now be called rangeoldtest.xls.

I want the file to be saved in the subfolder "old" if cell A1 contains the
text "old", or the file to be saved in the subfolder "new" if cell A1
contains the text "new"


Thanks again,

Pinda.

"Bob Phillips" wrote:

Close !

ActiveWorkbook.SaveAs "C:\files\Range" & Range("A1").Value &
ActiveWorkbook.Name


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Pinda" wrote in message
...
Hello,

The following code saves the active workbook in c:/files

ActiveWorkbook.SaveAs "C:\files\" & ActiveWorkbook.Name

However, I have two sub folders in c:\files,

c:\files\new\ and c:\files\old\

Is it possible to add a cell reference to the end of

ActiveWorkbook.SaveAs "C:\files\"

so I can type, for example, "old" or "new" in cell A1, and when I save

using
the above code, excel will save in the appropriate sub folder?

I have tried along the lines of:

ActiveWorkbook.SaveAs "C:\files\Range("A1")" & ActiveWorkbook.Name

but I cannot get it to work.

Thanks in advance.

Pinda.





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Using a cell reference in a filepath

Sorry, I wasn't careful enough, didn't see you hade the Range as well

ActiveWorkbook.SaveAs "C:\files\" & Range("A1").Value & "\" & _
ActiveWorkbook.Name

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Pinda" wrote in message
...
Bob,

Thanks again for the help, but the code you've given does not save the

file
in the subfolder (old), it just adds "rangeold" to the front of the

filename
and saves it in c:\files.


So if the file is called test.xls, it will now be called rangeoldtest.xls.

I want the file to be saved in the subfolder "old" if cell A1 contains the
text "old", or the file to be saved in the subfolder "new" if cell A1
contains the text "new"


Thanks again,

Pinda.

"Bob Phillips" wrote:

Close !

ActiveWorkbook.SaveAs "C:\files\Range" & Range("A1").Value &
ActiveWorkbook.Name


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Pinda" wrote in message
...
Hello,

The following code saves the active workbook in c:/files

ActiveWorkbook.SaveAs "C:\files\" & ActiveWorkbook.Name

However, I have two sub folders in c:\files,

c:\files\new\ and c:\files\old\

Is it possible to add a cell reference to the end of

ActiveWorkbook.SaveAs "C:\files\"

so I can type, for example, "old" or "new" in cell A1, and when I save

using
the above code, excel will save in the appropriate sub folder?

I have tried along the lines of:

ActiveWorkbook.SaveAs "C:\files\Range("A1")" & ActiveWorkbook.Name

but I cannot get it to work.

Thanks in advance.

Pinda.









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Using a cell reference in a filepath

Bob/Sean,

Bob u the man, thanks, I'm learning slowly but surely!

Thanks to Sean as wel,

In a bit,

Pinda

"Sean" wrote:

The code you entered was almost right, this should work

ActiveWorkbook.SaveAs "C:\files\" & Range("A1") & "\" &
ActiveWorkbook.Name

----
Sean
"Just press the off switch, and go to sleep!"

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cell value becomes filepath to insert picture,jpg or object Rookie_User Excel Worksheet Functions 0 February 6th 07 04:32 PM
Filepath Marie-Jo Excel Discussion (Misc queries) 3 July 5th 05 07:56 PM
Filepath Marie-Jo Excel Discussion (Misc queries) 2 June 30th 05 11:06 PM
Selecting a filepath based on cell contents ceemo Excel Discussion (Misc queries) 1 June 25th 05 01:40 PM
Insert Filepath into Cell Cameron[_5_] Excel Programming 2 April 2nd 04 07:12 AM


All times are GMT +1. The time now is 02:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"