+ Reply to Thread
Results 1 to 2 of 2

Add Filter to top row and reset page so (A1) is only cell highlighted

Hybrid View

  1. #1
    Registered User
    Join Date
    06-17-2013
    Location
    Greenfield, IN
    MS-Off Ver
    Excel 2007
    Posts
    70

    Add Filter to top row and reset page so (A1) is only cell highlighted

    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.

  2. #2
    Registered User
    Join Date
    06-17-2013
    Location
    Greenfield, IN
    MS-Off Ver
    Excel 2007
    Posts
    70

    Re: Add Filter to top row and reset page so (A1) is only cell highlighted

    Quote Originally Posted by floydian View Post
    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.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Click cell, link to a page, filter and sort data
    By spreaderman in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-12-2012, 03:47 AM
  2. Filter highlighted rows
    By assainar kutty in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-21-2008, 09:40 AM
  3. How to reset pivot table filter field box contents
    By gjcase in forum Excel General
    Replies: 3
    Last Post: 09-30-2008, 10:30 AM
  4. copy highlighted rows from Auto filter
    By tahirawan11 in forum Excel General
    Replies: 1
    Last Post: 06-19-2008, 12:00 PM
  5. [SOLVED] how to filter out highlighted cells
    By grlong in forum Excel General
    Replies: 2
    Last Post: 04-26-2006, 05:20 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1