rubertu_22
New Member
- Joined
- Apr 26, 2011
- Messages
- 9
Hello!
I need some help, this is the current macro I'm using, what I managed to get so far.
Option Explicit
Sub SvMe()
'Saves filename as value of A1 plus the current date
Dim newFile As String, fName As String
' Don't use "/" in date, invalid syntax
fName = Range("A7").Value
'Change the date format to whatever you'd like, but make sure it's in quotes
newFile = "Orçamento 000" & fName & "_" & Format$(Date, "yyyy")
' Change directory to suit your PC, including USER NAME
ChDir _
"D:\Users\Robby\Documents\Gigawatt\ELect"
ActiveWorkbook.SaveAs Filename:=newFile
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Worksheets("Sales Receipt").Range("a7").Value = Worksheets("Sales Receipt").Range("a7").Value + 1
End Sub
Private Sub Workbook_Open()
End Sub
What I'm trying to achieve is to have the main file edited and when i save that file, the changes are saved to another file which gets a estimate number, Orçamento 0002_2011, Orçamento 0003_2011, and so on, this new file is final so it can't have the macro being transported with it. The initial file(template) need to update the estimate number for next use.
Resuming
1st use
Template(cell as the number 001) file ->edit file-> run macro -> create file bla_bla_001_2011, and updates template cell(count of estimates) to 002.
2nd use
Template(cell as the number 002, updated on the previous use)-> edit file-> run macro -> create file bla_bla_002_2011, and updates template cell(count of estimates) to 003.
....
and so on.
Thanks in advance ,
I need some help, this is the current macro I'm using, what I managed to get so far.
Option Explicit
Sub SvMe()
'Saves filename as value of A1 plus the current date
Dim newFile As String, fName As String
' Don't use "/" in date, invalid syntax
fName = Range("A7").Value
'Change the date format to whatever you'd like, but make sure it's in quotes
newFile = "Orçamento 000" & fName & "_" & Format$(Date, "yyyy")
' Change directory to suit your PC, including USER NAME
ChDir _
"D:\Users\Robby\Documents\Gigawatt\ELect"
ActiveWorkbook.SaveAs Filename:=newFile
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Worksheets("Sales Receipt").Range("a7").Value = Worksheets("Sales Receipt").Range("a7").Value + 1
End Sub
Private Sub Workbook_Open()
End Sub
What I'm trying to achieve is to have the main file edited and when i save that file, the changes are saved to another file which gets a estimate number, Orçamento 0002_2011, Orçamento 0003_2011, and so on, this new file is final so it can't have the macro being transported with it. The initial file(template) need to update the estimate number for next use.
Resuming
1st use
Template(cell as the number 001) file ->edit file-> run macro -> create file bla_bla_001_2011, and updates template cell(count of estimates) to 002.
2nd use
Template(cell as the number 002, updated on the previous use)-> edit file-> run macro -> create file bla_bla_002_2011, and updates template cell(count of estimates) to 003.
....
and so on.
Thanks in advance ,