LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Using date in cell as variable

Sure...

Sub SaveFile()
Dim sFileName As String, sTest As String
sTest = Sheets("Sheet1").Range("C2").Text
If IsDate(sTest) = False Then
MsgBox "Sheet1 C2 is not a valid date", vbCritical, ""
Exit Sub
End If
sFileName = "C:\My Documents\" & _
Format(sTest, "yyyy\\dd-MM-yy") & _
".xls"
ActiveWorkbook.SaveAs sFileName
End Sub

....but the Folders must exist.

Regards - Steve.
"Patrick Simonds" wrote in message ...
On my spreadsheet cell C2 displays a date in the (04/27/05) format. What I need to do is have a macro which will save
the document to C:\My Documents\????\XXXXXX. Where ???? is the year in cell C2 and the XX-XX-XX is the date
(04-27-05). Is this possible?



 
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 capture a date variable within a text cell? Capture a variable date & use with text[_2_] Excel Discussion (Misc queries) 4 November 28th 08 02:34 AM
Setting a Date variable scott Excel Programming 4 January 28th 05 01:12 AM
Assign a Date Variable within VBA Q John Excel Programming 9 December 21st 04 04:46 PM
calc constant date from variable date & return with ability to rn. SusieQ'sQuest Excel Worksheet Functions 1 November 9th 04 08:51 PM
Compare Date in Cell VS a Variable Date to Hide Row JimI Excel Programming 3 October 10th 04 04:26 PM


All times are GMT +1. The time now is 04: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"