Originally Posted by
floydian
I have the following code and I would like to add two features.
1. Add the filter buttons to ROW A
2. Currently the colors appear to be off when you first open the new sheet, when in actuality it's simply that both the new sheets are fully selected. Can I reset the cursor to cell A1 so the colors all look correct on the new sheet?
' Copy Old Report and New Report to new workbook.
Dim NewName As String
Dim wb As Workbook
Dim nm As Name
Dim ws As Worksheet
Dim wksCopy As Worksheet
Dim strFullname As String
Application.EnableEvents = False
'// Copy specific sheets as in the named Array
Sheets(Array("New Report", "Old Report")).Copy
Set wb = ActiveWorkbook
For Each ws In wb.Worksheets
ws.UsedRange.Value = ws.UsedRange.Value
Next ws
'//Display Input box to name new file
NewName = InputBox("Please Specify the name of your new workbook", "Report")
'//Save it with the NewName and in the same directory as original
wb.SaveAs ThisWorkbook.Path & "\" & NewName & ".xls"
'wb.Close SaveChanges:=False
Application.EnableEvents = True
On Error Resume Next
' Kill strFullname
' END - Copy Old Report and New Report to new workbook.
I think I may have fixed it...
Does this look correct?
' Copy Old Report and New Report to new workbook.
Dim NewName As String
Dim wb As Workbook
Dim nm As Name
Dim ws As Worksheet
Dim wksCopy As Worksheet
Dim strFullname As String
Application.EnableEvents = False
'// Copy specific sheets as in the named Array
Sheets(Array("New Report", "Old Report")).Copy
Set wb = ActiveWorkbook
For Each ws In wb.Worksheets
ws.UsedRange.Value = ws.UsedRange.Value
Next ws
'//Display Input box to name new file
NewName = InputBox("Please Specify the name of your new workbook", "Report")
' Set up sheet so it is ready to go
Sheets("New Report").Select
'check for filter, turn on if none exists
If Not ActiveSheet.AutoFilterMode Then
ActiveSheet.Range("A1").AutoFilter
End If
Rows("1:1").Select
Sheets("Old Report").Select
'check for filter, turn on if none exists
If Not ActiveSheet.AutoFilterMode Then
ActiveSheet.Range("A1").AutoFilter
End If
Rows("1:1").Select
' END - Set up sheet so it is ready to go
'//Save it with the NewName and in the same directory as original
wb.SaveAs ThisWorkbook.Path & "\" & NewName & ".xls"
'wb.Close SaveChanges:=False
Application.EnableEvents = True
On Error Resume Next
' Kill strFullname
' END - Copy Old Report and New Report to new workbook.
Bookmarks