+ Reply to Thread
Results 1 to 6 of 6

Copy Multiple filtered data to same column

Hybrid View

  1. #1
    Registered User
    Join Date
    05-01-2013
    Location
    Cov, England
    MS-Off Ver
    Excel 2003
    Posts
    60

    Copy Multiple filtered data to same column

    Hi all

    I have a command button which filters data on worksheet "IdleTime" and copys the filtered data to to the worksheet "Idle Time M"
    The data is filtered by Month (selected by comboBox8 value) and the Time "8:00 PM"
    On "IdleTime" sheet Month is in Column 13 and time is in Column 2

    This code works fine, however i need to also Filter the "IdleTime" data with the same month (comboBox8 Value) but this time with the Time criteria "1:00 PM" Edit and criteria "Sat" (Field 14) . This filtered data needs to then be copied and pasted in the next free cell in "Idle Time M" after the data i had already pasted previously

    Currently having no luck trying to do this, please any help?

    Current Code which works for copy n paste for filtered data with just month and time 8pm
    Private Sub CommandButton12_Click()
    Dim iRow As Long
    
    If ComboBox8.Value = "" Then
    MsgBox "Please Select Month", vbExclamation, "Error"
    Me.ComboBox8.SetFocus
    Exit Sub
    End If
    If Not (Me.ComboBox8.Value = "April 13" Or Me.ComboBox8.Value = "May 13" Or Me.ComboBox8.Value = "June 13" Or Me.ComboBox8.Value = "July 13" Or Me.ComboBox8.Value = "August 13" Or Me.ComboBox8.Value = "September 13" Or Me.ComboBox8.Value = "October 13" Or Me.ComboBox8.Value = "November 13" Or Me.ComboBox8.Value = "December 13" Or Me.ComboBox8.Value = "January 14" Or Me.ComboBox8.Value = "February 14" Or Me.ComboBox8.Value = "March 14") Then
    MsgBox "Please Select Month From List", vbExclamation, "Idle Time"
    Me.ComboBox8.SetFocus
    Exit Sub
    End If
    
        Sheets("IdleTime").Select
        Cells.Select
        Selection.AutoFilter
        Selection.AutoFilter Field:=13, Criteria1:=UserForm1.ComboBox8.Value
        Selection.AutoFilter Field:=2, Criteria1:="8:00 PM"
        iRow = Cells(Rows.Count, "A").End(xlUp).Row
        Range("A1:L" & iRow).SpecialCells(xlCellTypeVisible).Copy
        Sheets("Idle Time M").Select
        Range("A2").Select
        ActiveSheet.Paste
        Sheets("IdleTime").Select
        Cells.Select
        Selection.AutoFilter
        Range("A2").Select
        Sheets("Idle Time M").Select
        Range("A2").Select
        MsgBox "Idle Time Summary", vbOKOnly + vbInformation, "Idle Time"
        Unload UserForm1
    End Sub
    Attached workbook aswell
    Edit: please see attached in my second post
    Command button 12 is located on phone performance summary Tab> Idle time/AQ Summary Tab> Idle Time summary Frame
    Attached Files Attached Files
    Last edited by flashdisk; 06-04-2013 at 02:05 AM.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Copy Multiple filtered data to same column

    Private Sub CommandButton12_Click()
        
        If Not Me.ComboBox8.ListIndex > -1 Then    'test if item from the list is selected
            MsgBox "Please Select Month From List", vbExclamation, "Idle Time"
            Me.ComboBox8.SetFocus
            Exit Sub
        End If
        
        Application.ScreenUpdating = False
        With Sheets("IdleTime").UsedRange
            .AutoFilter
            .AutoFilter Field:=13, Criteria1:=Me.ComboBox8.Value
            .AutoFilter Field:=2, Criteria1:="8:00 PM", _
                                  Operator:=xlOr, _
                                  Criteria2:="1:00 PM"
            'Sheets("Idle Time M").UsedRange.ClearContents
            .Resize(, 12).Copy Destination:=Sheets("Idle Time M").Range("A2")
            .AutoFilter
        End With
        Application.Goto Sheets("Idle Time M").Range("A2")
        Application.ScreenUpdating = True
        
        MsgBox "Idle Time Summary", vbOKOnly + vbInformation, "Idle Time"
        Unload UserForm1
        
    End Sub
    Last edited by AlphaFrog; 06-03-2013 at 08:54 PM.

  3. #3
    Registered User
    Join Date
    05-01-2013
    Location
    Cov, England
    MS-Off Ver
    Excel 2003
    Posts
    60

    Re: Copy Multiple filtered data to same column

    Hi Thanks for replying AlphaFrog

    Code looks great

    Apologies as i forgot to include another field in the second criteria which is why the data needs to be filtered separately and pasted below

    After it has copy n paste the filtered data for Criteria Month and Criteria 8 pm
    The second filter needs to be Criteria Month (Field 13), Criteria "1:00 PM" (Field 2), and Criteria "Sat" (Field 14)
    This is due to end of day values being entered at 8pm on weekdays and 1pm on a saturday
    Hope this makes sense?

    have attached workbook again with field 14 in IdleTime Sheet
    Attached Files Attached Files

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Copy Multiple filtered data to same column

    Private Sub CommandButton12_Click()
        
        If Not Me.ComboBox8.ListIndex > -1 Then    'test if item from the list is selected
            MsgBox "Please Select Month From List", vbExclamation, "Idle Time"
            Me.ComboBox8.SetFocus
            Exit Sub
        End If
        
        Application.ScreenUpdating = False
        With Sheets("IdleTime").UsedRange
            .AutoFilter
            .AutoFilter Field:=13, Criteria1:=Me.ComboBox8.Value
            .AutoFilter Field:=2, Criteria1:="8:00 PM"
            'Sheets("Idle Time M").UsedRange.ClearContents
            .Resize(, 12).Copy Destination:=Sheets("Idle Time M").Range("A2")
            
            .AutoFilter Field:=2, Criteria1:="1:00 PM"
            .AutoFilter Field:=14, Criteria1:="Sat"
            .Resize(, 12).Offset(1).Copy _
                Destination:=Sheets("Idle Time M").Range("A" & Rows.Count).End(xlUp).Offset(1)
            
            .AutoFilter
            
        End With
        Application.Goto Sheets("Idle Time M").Range("A2")
        Application.ScreenUpdating = True
        
        MsgBox "Idle Time Summary", vbOKOnly + vbInformation, "Idle Time"
        Unload UserForm1
        
    End Sub

  5. #5
    Registered User
    Join Date
    05-01-2013
    Location
    Cov, England
    MS-Off Ver
    Excel 2003
    Posts
    60

    Re: Copy Multiple filtered data to same column

    Hi Thanks again for repying

    When testing the code i get a debug error on the below line?
    .Resize(, 12).Copy Destination:=Sheets("Idle Time M").Range("A2")

  6. #6
    Registered User
    Join Date
    05-01-2013
    Location
    Cov, England
    MS-Off Ver
    Excel 2003
    Posts
    60

    Re: Copy Multiple filtered data to same column

    Found the cause, works great. Thank you

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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