ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Svae file within macro (https://www.excelbanter.com/excel-programming/360383-svae-file-within-macro.html)

lee

Svae file within macro
 
How do I save a file automaticaly with a variable file name. Eg I want to
save a file twice a day at the end of each shift (info to be contained within
an established macro) with the date as a file name with am or pm added to the
end to signify which shift the info is from.

Can anyone help please???

dok112[_144_]

Svae file within macro
 

Sub FileSave()
Dim D As Variant
Dim T As Variant
[D] = Format(Date, "mm-dd-yyyy")
If Time = "12:00 PM" Then
[T] = "PM"
End If
If Time <= "12:00 AM" Then
[T] = "AM"
End If

ThisWorkbook.SaveAs Filename:="" & [D] & " " & [T] & ""

End Sub


--
dok112
------------------------------------------------------------------------
dok112's Profile: http://www.excelforum.com/member.php...o&userid=10581
View this thread: http://www.excelforum.com/showthread...hreadid=538238


XCESIV[_8_]

Svae file within macro
 

I would like something very similar.

I would like it to save using the date of the wages fortnight.

I would like mine to save with "FNE " then the date like in the e
which is in cell named "PAY_PERIOD" which is C5 in Balance sheet.
eg
"FNE 07_03_05.xls"
"FNE 07_17_05.xls"
"FNE 07_31_05.xls

--
XCESI
-----------------------------------------------------------------------
XCESIV's Profile: http://www.excelforum.com/member.php...fo&userid=2427
View this thread: http://www.excelforum.com/showthread.php?threadid=53823


XCESIV[_10_]

Svae file within macro
 

How do i get d to = a cell in the workbook


--
XCESIV
------------------------------------------------------------------------
XCESIV's Profile: http://www.excelforum.com/member.php...o&userid=24271
View this thread: http://www.excelforum.com/showthread...hreadid=538238


Dave Peterson

Svae file within macro
 
dim myFileName as string
myfilename = "c:\yourpathhere\" & "FNE" _
& format(worksheets("balance").range("C5").value, "dd_mm_yyyy") _
& ".xls"

activeworkbook.saveas filename:=myfilename, fileformat:=xlworkbooknormal

XCESIV wrote:

I would like something very similar.

I would like it to save using the date of the wages fortnight.

I would like mine to save with "FNE " then the date like in the eg
which is in cell named "PAY_PERIOD" which is C5 in Balance sheet.
eg
"FNE 07_03_05.xls"
"FNE 07_17_05.xls"
"FNE 07_31_05.xls"

--
XCESIV
------------------------------------------------------------------------
XCESIV's Profile: http://www.excelforum.com/member.php...o&userid=24271
View this thread: http://www.excelforum.com/showthread...hreadid=538238


--

Dave Peterson


All times are GMT +1. The time now is 01:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com