austin350s10
Active Member
- Joined
- Jul 30, 2010
- Messages
- 321
I am working on a multi-sheet workbook that captures data over a one year span. After the new year I would like a script that backs-up the current workbook, saving it with a specific file format, something like:
"string cell reference"," ","old year".
The tricky part is when it is finished backing-up the workbook I would like the script to also clear out large chunks of data in most of the non-protected cells including many checkboxes. This is so the user can begin to re-enter data for the new year without loosing important data like names and phone numbers...est.
Lastly, when it is finished clearing out the data it should automaticly save the workbook again with a specific file format something like:
"string cell reference"," ","new year".
How can this be done??
The only part I know how to do write a script that runs when the new year is detected just don't know the back-up and clearing of contents portion:
"string cell reference"," ","old year".
The tricky part is when it is finished backing-up the workbook I would like the script to also clear out large chunks of data in most of the non-protected cells including many checkboxes. This is so the user can begin to re-enter data for the new year without loosing important data like names and phone numbers...est.
Lastly, when it is finished clearing out the data it should automaticly save the workbook again with a specific file format something like:
"string cell reference"," ","new year".
How can this be done??
The only part I know how to do write a script that runs when the new year is detected just don't know the back-up and clearing of contents portion:
Code:
[B][B]Sub test()
Dim CurrentYear As Integer
Dim NextYear As Integer
CurrentYear = Application.WorksheetFunction.Text(Date, "yyyy")
[/B]NextYear = Range("D6").Value 'next year is in D6 the first time "Lets Say 2011"[/B]
[B][B]
If CurrentYear = NextYear Then
MsgBox ("The macro has worked")
[/B]Range("D6").Value = NextYear + 1 'Should change the original value of 2011 to 2012[/B][B][B]
End If
End Sub[/B][/B]</pre>