B
Boiler-Todd
I am new to using VBA so let me explain what I am trying to do...
I want to be able to copy 3 tabs(sheets) in a workbook into 3 new
tabs(sheets) into the same workbook. Also if the date is two days later then
I want to delete values on the orignal sheets. I also want to do this
everytime the sheet is opened.
My current code loops to copy each sheet three times and then deletes data
on the copied sheets but not the original sheets. See below. Thanks for all
help!
Sub Workbook_Open()
' This Macro will copy sheets 1-2-3 to new sheets A-B-C then
' if date is 2 days past clear out the UNLOCKED cells of a sheets (1-3)
'
Dim cell As Range
For Each sh In ActiveWorkbook.Sheets
If Date > sh.Range("A1").Value - 2 Then
Sheets(1).Copy After:=Sheets(Sheets.Count)
Sheets(2).Copy After:=Sheets(Sheets.Count)
Sheets(3).Copy After:=Sheets(Sheets.Count)
For Each cell In Range("A1:H10")
If Not cell.Locked Then cell.ClearContents
Next cell
End If
Next
End Sub
I want to be able to copy 3 tabs(sheets) in a workbook into 3 new
tabs(sheets) into the same workbook. Also if the date is two days later then
I want to delete values on the orignal sheets. I also want to do this
everytime the sheet is opened.
My current code loops to copy each sheet three times and then deletes data
on the copied sheets but not the original sheets. See below. Thanks for all
help!
Sub Workbook_Open()
' This Macro will copy sheets 1-2-3 to new sheets A-B-C then
' if date is 2 days past clear out the UNLOCKED cells of a sheets (1-3)
'
Dim cell As Range
For Each sh In ActiveWorkbook.Sheets
If Date > sh.Range("A1").Value - 2 Then
Sheets(1).Copy After:=Sheets(Sheets.Count)
Sheets(2).Copy After:=Sheets(Sheets.Count)
Sheets(3).Copy After:=Sheets(Sheets.Count)
For Each cell In Range("A1:H10")
If Not cell.Locked Then cell.ClearContents
Next cell
End If
Next
End Sub