OldSoldier
New Member
- Joined
- Mar 29, 2011
- Messages
- 13
Hello. I am trying to copy two parts of a table, one section just having values and the other having formulas, to a new worksheet with the new worksheet taking on the name of the contents of cell A2.
Cell A2 has the name of the the data set results of a drop-down result set run by a filter macro. I am first copying the entire table in and then I am copying the formula section in to where it belongs.
The formulas do not transfer when I copy the entire table; yet data validation fields, which I want to maintain in the non-formula copied over section, do come over.
It would all work fine, except that I cannot find a way to refer back to my newly-named worksheet (as a generic new or last-activated worksheet) in order to paste my second section (StaffCounts).
Can anybody help with this?
The code, such as it is, is below.
Dim NewSheet As Worksheet
Sheets("Report").Select
Application.Goto Reference:="ReportArea"
Selection.Copy
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Paste
Sheets(Sheets.Count).Name = Sheets(Sheets.Count).Range("A2").Value
Application.CutCopyMode = False
Set NewSheet = ActiveSheet
'NewSheet = ActiveSheet.Range("A2").Value
Sheets("Report").Select
Application.Goto Reference:="StaffCounts"
Selection.Copy After:=Sheets(NewSheet).Range("U1").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("A4").Select
ActiveWindow.FreezePanes = True
Selection.End(xlDown).Select
'Selection.End(xlDown).Select
'Sheets("Sheet1").Name = MsgBox("Rename Sheet")
End Sub
Thanks!!
Cell A2 has the name of the the data set results of a drop-down result set run by a filter macro. I am first copying the entire table in and then I am copying the formula section in to where it belongs.
The formulas do not transfer when I copy the entire table; yet data validation fields, which I want to maintain in the non-formula copied over section, do come over.
It would all work fine, except that I cannot find a way to refer back to my newly-named worksheet (as a generic new or last-activated worksheet) in order to paste my second section (StaffCounts).
Can anybody help with this?
The code, such as it is, is below.
Dim NewSheet As Worksheet
Sheets("Report").Select
Application.Goto Reference:="ReportArea"
Selection.Copy
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Paste
Sheets(Sheets.Count).Name = Sheets(Sheets.Count).Range("A2").Value
Application.CutCopyMode = False
Set NewSheet = ActiveSheet
'NewSheet = ActiveSheet.Range("A2").Value
Sheets("Report").Select
Application.Goto Reference:="StaffCounts"
Selection.Copy After:=Sheets(NewSheet).Range("U1").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Range("A4").Select
ActiveWindow.FreezePanes = True
Selection.End(xlDown).Select
'Selection.End(xlDown).Select
'Sheets("Sheet1").Name = MsgBox("Rename Sheet")
End Sub
Thanks!!