Consulting

Results 1 to 2 of 2

Thread: Copy certain columns of data from 2 worksheets that are auto-filtered to 1 summary wo

  1. #1

    Copy certain columns of data from 2 worksheets that are auto-filtered to 1 summary wo

    Hi everyone, I am a macro beginner. I have two worksheets with source data (layout of each worksheet is the same but number of rows on each sheet will continue to grow). In these 2 sheets 'WTP' and 'RMARN' I've managed to create a macro to autofilter (Filter on column F - Filter out any rows that are "Finished") - macro button top left). This column F is also a formula. My other macro is simply to clear the filter. What I need is a macro to copy certain columns from both of these source data sheets (rows that are not “Finished” in column F) and copy paste as values in the 'Summary' sheet. I need to do this monthly so each time I run it I need to clear what is in the summary sheet from last time and run the macro again (replace what was already there). The columns I need to copy from the two source sheets are shown in the summary tab in attached - B C D E F O P & U. But I don't want the column headers to come through to the summary sheet when I run the macro. Ive only shown them on the summary sheet this time as a guide. There are broken formulas in the source sheets please ignore them. Their source data was confidential but those columns do have to stay there. I've been on internet all day trying to build this macro & have failed. Also tried recording then editing it but got completely lost. Can anyone help? Must confess I'm hoping someone can do it for me then I can study it! Thank you
    Attached Files Attached Files

  2. #2
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    First focus on 'why'.
    Why would you copy data ?
    The combination of autofilter and hidden columns gives the same result.

    Sub M_snb()
       Sheet1.Range("A1,G1:N1,Q1:T1,V1:AK1").EntireColumn.Hidden = True
       Sheet1.Cells(5, 1).CurrentRegion.AutoFilter 6, "<>Finished"
    End Sub
    To restore:
    Sub M_snb_restore()
       sheet1.columns.hidden =false
       Sheet1.Cells(5, 1).CurrentRegion.AutoFilter
    End Sub

Posting Permissions

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