Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default help required with using cells to generate a filename

is there a way of clicking on a button that asks you where you want
the file saving, but enters in a filename derived from the contents
of two cells and todays date?

for example if cell A1 contained 'hello' and cell B12 contained
'world' the prompted filename would be 'hello - world - 200306.xls'.

Any help would be appreciated.

TIA
--
----------------------------------------------
Posted with NewsLeecher v3.0 Final
* Binary Usenet Leeching Made Easy
* http://www.newsleecher.com/?usenet
----------------------------------------------
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default help required with using cells to generate a filename

Try something like this.

Dim sCell1 As String
Dim sCell2 As String
Dim DateStamp As String

sCell1 = Sheet1.Cells(1, 1).Value
sCell2 = Sheet2.Cells(1, 2).Value
DateStamp = Format(Date, "YYYYMMDD")

Application.GetSaveAsFilename sCell1 & " - " & _
sCell2 & " - " & _
DateStamp & ".XLS"

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default help required with using cells to generate a filename

look at the getsaveasfilename

it has an InitialFilename argument

With Activeworkbook.worksheets(1)
fname = Application.GetSaveAsFilename InitialFilename:= _
"C:\My Folder\" & .Range("A1").Text & _
" - " & .Range("B12").text & " - " & _
format(Date,"yyyymm") & ".xls"
End with
Activeworkbook.SaveAs fname
But the user could always change it. If you just want to save the file with
the given name
with worksheets(1)
Activeworkbook.Saveas "C:\My Folder\" & .Range("A1").Text & _
" - " & .Range("B12").text & " - " & _
format(Date,"yyyymm") & ".xls"
End with

--
Regards,
Tom Ogilvy

"Bungle" wrote:

is there a way of clicking on a button that asks you where you want
the file saving, but enters in a filename derived from the contents
of two cells and todays date?

for example if cell A1 contained 'hello' and cell B12 contained
'world' the prompted filename would be 'hello - world - 200306.xls'.

Any help would be appreciated.

TIA
--
----------------------------------------------
Posted with NewsLeecher v3.0 Final
* Binary Usenet Leeching Made Easy
* http://www.newsleecher.com/?usenet
----------------------------------------------

  #4   Report Post  
Posted to microsoft.public.excel.programming
Jay Jay is offline
external usenet poster
 
Posts: 671
Default help required with using cells to generate a filename

You could also try this, Bungle, which is a variation of the previous two
suggestions. Copy it into your VBA editor work area; it's ready to run.
--Jay

Sub fileNameFromCellContentsAndDate()
With ActiveWorkbook.ActiveSheet
'First part of filename...
a = Range("A1").Value & " - " & Range("B1").Value & " - "

'Date part of filename
b = Format(Date, "ddmmyy")

'Filename extension...
c = ".xls"

'Use a variable name that is different from 'filename' because filename
is a VBA keyword
s_filename = a + b + c

fname = Application.GetSaveAsFilename(InitialFileName:=s_f ilename)
ActiveWorkbook.SaveAs Filename:=fname
End With
End Sub


"Bungle" wrote:

is there a way of clicking on a button that asks you where you want
the file saving, but enters in a filename derived from the contents
of two cells and todays date?

for example if cell A1 contained 'hello' and cell B12 contained
'world' the prompted filename would be 'hello - world - 200306.xls'.

Any help would be appreciated.

TIA
--
----------------------------------------------
Posted with NewsLeecher v3.0 Final
* Binary Usenet Leeching Made Easy
* http://www.newsleecher.com/?usenet
----------------------------------------------

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
Generate a filename from cell range? Anyone. fail2excel Excel Discussion (Misc queries) 3 July 20th 09 03:14 PM
HOW TO i HAVE OTHER CELLS GENERATE CONSECTUIVE MONTHS Cathy in Florida Excel Discussion (Misc queries) 1 July 15th 06 03:17 PM
generate a random number and use if function to generate new data Dogdoc1142 Excel Worksheet Functions 4 April 26th 06 03:44 AM
Generate absolute hyperlinks to cells Loïc Excel Discussion (Misc queries) 0 October 8th 05 10:24 AM
Using TODAY() to generate a filename from where values are VLOOKUPed dolik Links and Linking in Excel 2 June 14th 05 11:53 PM


All times are GMT +1. The time now is 03:46 PM.

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

About Us

"It's about Microsoft Excel"