LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default Macro to change directory based on cell content

Hi Rick,

When I tried your first suggestion: ChDir "G:\" & Range("A1").Value &
"\Pending WRO", it saved the file to the current directory I was working in.
Your second suggestion works perfectly.

Thank you for all your help
--
Linda


"Rick Rothstein (MVP - VB)" wrote:

I am new to Excel and have created a document that has a drop down list at
the top to change the header from 'Bank' to 'Savings'. I read in the
discussion group how to automatically save a file using a cell reference.
I
must change directories, before saving and so far what I have (and it
works)
is:

ChDir "G:\SAVINGS\Pending WRO"
ActiveWorkbook.SaveAs Filename:=Range("b8").Value

What I need to accomplish is in the active workbook, if Cell A1 =
'Savings',
then
ChDir "G:\SAVINGS\Pending WRO"
ActiveWorkbook.SaveAs Filename:=Range("b8").Value
But if Cell A1 = 'Bank' then
ChDir "G:\Bank\Pending WRO"
ActiveWorkbook.SaveAs Filename:=Range("b8").Value


Maybe this line of code does what you want?

ChDir "G:\" & Range("A1").Value & "\Pending WRO"

Personally, I wouldn't bother with setting the ChDir at all; I would
eliminate the ChDir statement completely and just prepend the path onto the
value from B8...

ActiveWorkbook.SaveAs Filename:="G:\" & Range("A1").Value & _
"\Pending WRO\" & Range("B8").Value

Rick


 
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
how to change a cell color based on its content using macro? Ranger888 New Users to Excel 6 December 15th 08 08:23 PM
Change a cell based on current content. Mahnian Excel Programming 2 May 3rd 07 06:47 PM
how do I change the content of one cell based on another? Barry Excel Discussion (Misc queries) 2 September 3rd 06 10:16 AM
Change the data in one cell based on content of another. Barry Excel Discussion (Misc queries) 2 September 3rd 06 08:26 AM
How do I change content of a cell based on date diving1 Excel Worksheet Functions 2 December 19th 04 08:39 PM


All times are GMT +1. The time now is 10:23 PM.

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"