![]() |
Naming and saving a workbook
I want to be able to open a new workbook (which I can do) then save it as
workbook name + (value in B1 on open workbook, which will be a date).xls How do I do this. I can open the workbook and name it and save it, but I want to be able to add the date in B1 to the name. Thanks. |
Naming and saving a workbook
Post the code that you have so far...
-- HTH... Jim Thomlinson "Kevin Porter" wrote: I want to be able to open a new workbook (which I can do) then save it as workbook name + (value in B1 on open workbook, which will be a date).xls How do I do this. I can open the workbook and name it and save it, but I want to be able to add the date in B1 to the name. Thanks. |
Naming and saving a workbook
Sub CreateDetailWB()
' ' CreateDetailWB Macro ' Macro recorded 2/20/2007 by Kevin Porter ' ' Dim WBDate As String WBDate = Workbooks("SRA Payroll Details.xlt").Sheets("List").Cells(A2) Workbooks.Add Sheets("Sheet3").Select ActiveWindow.SelectedSheets.Delete Sheets("Sheet2").Select ActiveWindow.SelectedSheets.Delete ChDir "\\dc\SRAO\Intuit\Payroll 2007" ActiveWorkbook.SaveAs Filename:= _ "\\dc\SRAO\Intuit\Payroll 2007\SRA Detailed Payroll - " & WBDate & ".xls", FileFormat:= _ xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _ , CreateBackup:=False End Sub "Jim Thomlinson" wrote: Post the code that you have so far... -- HTH... Jim Thomlinson "Kevin Porter" wrote: I want to be able to open a new workbook (which I can do) then save it as workbook name + (value in B1 on open workbook, which will be a date).xls How do I do this. I can open the workbook and name it and save it, but I want to be able to add the date in B1 to the name. Thanks. |
Naming and saving a workbook
Do you mean cell A2 in SRA Payroll Details contains the date you want to add
to the filename? If so, then: WBDate = Format(Workbooks("SRA Payroll Details.xlt").Sheets("List").Cells(A2), "yyyymmdd") "Kevin Porter" wrote in message ... Sub CreateDetailWB() ' ' CreateDetailWB Macro ' Macro recorded 2/20/2007 by Kevin Porter ' ' Dim WBDate As String WBDate = Workbooks("SRA Payroll Details.xlt").Sheets("List").Cells(A2) Workbooks.Add Sheets("Sheet3").Select ActiveWindow.SelectedSheets.Delete Sheets("Sheet2").Select ActiveWindow.SelectedSheets.Delete ChDir "\\dc\SRAO\Intuit\Payroll 2007" ActiveWorkbook.SaveAs Filename:= _ "\\dc\SRAO\Intuit\Payroll 2007\SRA Detailed Payroll - " & WBDate & ".xls", FileFormat:= _ xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _ , CreateBackup:=False End Sub "Jim Thomlinson" wrote: Post the code that you have so far... -- HTH... Jim Thomlinson "Kevin Porter" wrote: I want to be able to open a new workbook (which I can do) then save it as workbook name + (value in B1 on open workbook, which will be a date).xls How do I do this. I can open the workbook and name it and save it, but I want to be able to add the date in B1 to the name. Thanks. ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups ----= East and West-Coast Server Farms - Total Privacy via Encryption =---- |
Naming and saving a workbook
correction:
WBDate = Format(Workbooks("SRA Payroll Details.xlt").Sheets("List").Range("A2").text, "yyyymmdd") "Vergel Adriano" wrote in message ... Do you mean cell A2 in SRA Payroll Details contains the date you want to add to the filename? If so, then: WBDate = Format(Workbooks("SRA Payroll Details.xlt").Sheets("List").Cells(A2), "yyyymmdd") "Kevin Porter" wrote in message ... Sub CreateDetailWB() ' ' CreateDetailWB Macro ' Macro recorded 2/20/2007 by Kevin Porter ' ' Dim WBDate As String WBDate = Workbooks("SRA Payroll Details.xlt").Sheets("List").Cells(A2) Workbooks.Add Sheets("Sheet3").Select ActiveWindow.SelectedSheets.Delete Sheets("Sheet2").Select ActiveWindow.SelectedSheets.Delete ChDir "\\dc\SRAO\Intuit\Payroll 2007" ActiveWorkbook.SaveAs Filename:= _ "\\dc\SRAO\Intuit\Payroll 2007\SRA Detailed Payroll - " & WBDate & ".xls", FileFormat:= _ xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _ , CreateBackup:=False End Sub "Jim Thomlinson" wrote: Post the code that you have so far... -- HTH... Jim Thomlinson "Kevin Porter" wrote: I want to be able to open a new workbook (which I can do) then save it as workbook name + (value in B1 on open workbook, which will be a date).xls How do I do this. I can open the workbook and name it and save it, but I want to be able to add the date in B1 to the name. Thanks. ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups ----= East and West-Coast Server Farms - Total Privacy via Encryption =---- ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups ----= East and West-Coast Server Farms - Total Privacy via Encryption =---- |
Naming and saving a workbook
Seems to me, using the Text property to pass a date string to format would
increase the possibility of misinterpretation which would be avoided by using Value WBDate = Format(Workbooks("SRA Payroll Details.xlt").Sheets("List").Range("A2").Value, "yyyymmdd") -- Regards, Tom Ogilvy "Vergel Adriano" wrote: correction: WBDate = Format(Workbooks("SRA Payroll Details.xlt").Sheets("List").Range("A2").text, "yyyymmdd") "Vergel Adriano" wrote in message ... Do you mean cell A2 in SRA Payroll Details contains the date you want to add to the filename? If so, then: WBDate = Format(Workbooks("SRA Payroll Details.xlt").Sheets("List").Cells(A2), "yyyymmdd") "Kevin Porter" wrote in message ... Sub CreateDetailWB() ' ' CreateDetailWB Macro ' Macro recorded 2/20/2007 by Kevin Porter ' ' Dim WBDate As String WBDate = Workbooks("SRA Payroll Details.xlt").Sheets("List").Cells(A2) Workbooks.Add Sheets("Sheet3").Select ActiveWindow.SelectedSheets.Delete Sheets("Sheet2").Select ActiveWindow.SelectedSheets.Delete ChDir "\\dc\SRAO\Intuit\Payroll 2007" ActiveWorkbook.SaveAs Filename:= _ "\\dc\SRAO\Intuit\Payroll 2007\SRA Detailed Payroll - " & WBDate & ".xls", FileFormat:= _ xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _ , CreateBackup:=False End Sub "Jim Thomlinson" wrote: Post the code that you have so far... -- HTH... Jim Thomlinson "Kevin Porter" wrote: I want to be able to open a new workbook (which I can do) then save it as workbook name + (value in B1 on open workbook, which will be a date).xls How do I do this. I can open the workbook and name it and save it, but I want to be able to add the date in B1 to the name. Thanks. ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups ----= East and West-Coast Server Farms - Total Privacy via Encryption =---- ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups ----= East and West-Coast Server Farms - Total Privacy via Encryption =---- |
Naming and saving a workbook
Thank you. Worked like a dream.
"Vergel Adriano" wrote: correction: WBDate = Format(Workbooks("SRA Payroll Details.xlt").Sheets("List").Range("A2").text, "yyyymmdd") "Vergel Adriano" wrote in message ... Do you mean cell A2 in SRA Payroll Details contains the date you want to add to the filename? If so, then: WBDate = Format(Workbooks("SRA Payroll Details.xlt").Sheets("List").Cells(A2), "yyyymmdd") "Kevin Porter" wrote in message ... Sub CreateDetailWB() ' ' CreateDetailWB Macro ' Macro recorded 2/20/2007 by Kevin Porter ' ' Dim WBDate As String WBDate = Workbooks("SRA Payroll Details.xlt").Sheets("List").Cells(A2) Workbooks.Add Sheets("Sheet3").Select ActiveWindow.SelectedSheets.Delete Sheets("Sheet2").Select ActiveWindow.SelectedSheets.Delete ChDir "\\dc\SRAO\Intuit\Payroll 2007" ActiveWorkbook.SaveAs Filename:= _ "\\dc\SRAO\Intuit\Payroll 2007\SRA Detailed Payroll - " & WBDate & ".xls", FileFormat:= _ xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _ , CreateBackup:=False End Sub "Jim Thomlinson" wrote: Post the code that you have so far... -- HTH... Jim Thomlinson "Kevin Porter" wrote: I want to be able to open a new workbook (which I can do) then save it as workbook name + (value in B1 on open workbook, which will be a date).xls How do I do this. I can open the workbook and name it and save it, but I want to be able to add the date in B1 to the name. Thanks. ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups ----= East and West-Coast Server Farms - Total Privacy via Encryption =---- ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups ----= East and West-Coast Server Farms - Total Privacy via Encryption =---- |
All times are GMT +1. The time now is 11:14 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com