Hello! I'm trying to create a code that will copy and paste information to a new tab and rename the tab using the date that's in cell A2. The date will change every month and is in the format 'March 2011'. Here's what I have so far:
Sub NewTab()
Sheets("List").Select
Cells.Select
Selection.Copy
Dim ws As Worksheet
Set ws = Sheets.Add
ws.Name = "Temp"
Sheets("Temp").Select
Cells.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("A2:E2").Select
Selection.UnMerge
Range("A2").Select
Sheets("Temp").Name = Range("a2")
Range("A1").Select
End Sub
This probably isn't the best code to use, but it works as long as I have anything in cell A2, except a date. For some reason a date causes an error. I've also considered using a code that just names the tab with the prior month date. Example: In March, rename the tab February 2011. But I'm not sure how to do that. I'd really appreciate any help.
Thanks!
Jodi
Sub NewTab()
Sheets("List").Select
Cells.Select
Selection.Copy
Dim ws As Worksheet
Set ws = Sheets.Add
ws.Name = "Temp"
Sheets("Temp").Select
Cells.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Range("A2:E2").Select
Selection.UnMerge
Range("A2").Select
Sheets("Temp").Name = Range("a2")
Range("A1").Select
End Sub
This probably isn't the best code to use, but it works as long as I have anything in cell A2, except a date. For some reason a date causes an error. I've also considered using a code that just names the tab with the prior month date. Example: In March, rename the tab February 2011. But I'm not sure how to do that. I'd really appreciate any help.
Thanks!
Jodi