![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Feb 2002
Posts: 43
|
I have a spreadsheet that pulls info from a database. I want to add a macro to save the file, with the file name being the contents of a cell in the sheet. I want to use an input box though, with the contents of that cell as the suggested input(similar to the save as box). That way the user can change it if necessary.
[ This Message was edited by: DaKen on 2002-02-19 09:08 ] |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,927
|
Have a look at this:
Application.GetSaveAsFilename |
|
|
|
|
|
#3 |
|
New Member
Join Date: Feb 2002
Posts: 43
|
Can the contents of a cell be placed in the file name input section?
[ This Message was edited by: DaKen on 2002-02-19 09:33 ] |
|
|
|
|
|
#4 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
How's this:
fname = InputBox("Name the file", "Howdy", Range("a1") & ".xls") If fname <> "" Then ActiveWorkbook.saveas Filename:=fname End If Cheers, Nate [ This Message was edited by: NateO on 2002-02-19 11:37 ] |
|
|
|
|
|
#5 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
The answer to your second question is Yes. And it's better than using an input box:
Sub save_itas2() fname = Application.GetSaveAsFilename _ (InitialFilename:=Range("a1"), _ FileFilter:="Excel Files (*.xls),*.xls", FilterIndex:=0, Title:="Save As") If fname <> "False" Then ActiveWorkbook.saveas Filename:=fname End If End Sub Cheers, Nate |
|
|
|
|
|
#6 |
|
New Member
Join Date: Feb 2002
Posts: 43
|
This worked great!! Is there any way to pull the date from a cell that is "=today()" in a format that can be saved as part of the file name?
|
|
|
|
|
|
#7 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Why pull the date from a cell? How's this:
Sub save_itas3() fname = Application.GetSaveAsFilename _ (InitialFilename:=Range("a1") & " " & WorksheetFunction.Substitute(Date, "/", "_"), _ FileFilter:="Excel Files (*.xls),*.xls", FilterIndex:=0, Title:="Save As") If fname <> "False" Then ActiveWorkbook.SaveAs Filename:=fname End If End Sub Cheers, Nate [ This Message was edited by: NateO on 2002-02-19 20:13 ] |
|
|
|
|
|
#8 |
|
New Member
Join Date: Feb 2002
Posts: 43
|
I tried that, but it returns 2/19/2002 which won't work. I'd have to get rid of the "/" somehow!
|
|
|
|
|
|
#9 |
|
Legend
Join Date: Feb 2002
Location: Minneapolis, Mn, USA
Posts: 9,704
|
Yep, I edited that post. Try the code posted now.
Cheers, Nate |
|
|
|
|
|
#10 |
|
New Member
Join Date: Feb 2002
Posts: 43
|
Bingo!!! Thanks a bunch!
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|