Results 1 to 4 of 4

Copy and Paste Values based on column data

Threaded View

  1. #1
    Registered User
    Join Date
    08-20-2013
    Location
    Minnesota, USA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Copy and Paste Values based on column data

    I would like to copy and paste the values from a worksheet (HS-Detail) in a file to different tabs depending on the value in column A (Regions). I have a macro that works but it pastes the formulas and it takes quiet a while to run due to the number of records. How can I alter this to paste just the values and speed up the macro?


    rcnt = ActiveWorkbook.Sheets("HS - Detail").Range("A" & Rows.Count).End(xlUp).Row
        MTrec = ActiveWorkbook.Sheets("MOUNTAIN").Range("A" & Rows.Count).End(xlUp).Row
        NCrec = ActiveWorkbook.Sheets("NORTH CENTRAL").Range("A" & Rows.Count).End(xlUp).Row
        NErec = ActiveWorkbook.Sheets("NORTHEAST").Range("A" & Rows.Count).End(xlUp).Row
        SCrec = ActiveWorkbook.Sheets("SOUTH CENTRAL").Range("A" & Rows.Count).End(xlUp).Row
        SErec = ActiveWorkbook.Sheets("SOUTHEAST").Range("A" & Rows.Count).End(xlUp).Row
        WErec = ActiveWorkbook.Sheets("WEST").Range("A" & Rows.Count).End(xlUp).Row
    
        For i = 8 To rcnt
            If ActiveWorkbook.Sheets("HS - Detail").Range("A" & i).Value = "MOUNTAIN" Then
                MTrec = MTrec + 1
                ActiveWorkbook.Sheets("HS - Detail").Rows(i & ":" & i).Copy (ActiveWorkbook.Sheets("MOUNTAIN").Range("A" & MTrec))
            ElseIf ActiveWorkbook.Sheets("HS - Detail").Range("A" & i).Value = "NORTH CENTRAL" Then
                NCrec = NCrec + 1
                ActiveWorkbook.Sheets("HS - Detail").Rows(i & ":" & i).Copy (ActiveWorkbook.Sheets("NORTH CENTRAL").Range("A" & NCrec))
            ElseIf ActiveWorkbook.Sheets("HS - Detail").Range("A" & i).Value = "WEST" Then
                WErec = WErec + 1
                ActiveWorkbook.Sheets("HS - Detail").Rows(i & ":" & i).Copy (ActiveWorkbook.Sheets("WEST").Range("A" & WErec))
            ElseIf ActiveWorkbook.Sheets("HS - Detail").Range("A" & i).Value = "NORTHEAST" Then
                NErec = NErec + 1
                ActiveWorkbook.Sheets("HS - Detail").Rows(i & ":" & i).Copy (ActiveWorkbook.Sheets("NORTHEAST").Range("A" & NErec))
            ElseIf ActiveWorkbook.Sheets("HS - Detail").Range("A" & i).Value = "SOUTHEAST" Then
                SErec = SErec + 1
                ActiveWorkbook.Sheets("HS - Detail").Rows(i & ":" & i).Copy (ActiveWorkbook.Sheets("SOUTHEAST").Range("A" & SErec))
            ElseIf ActiveWorkbook.Sheets("HS - Detail").Range("A" & i).Value = "SOUTH CENTRAL" Then
                SCrec = SCrec + 1
                ActiveWorkbook.Sheets("HS - Detail").Rows(i & ":" & i).Copy (ActiveWorkbook.Sheets("SOUTH CENTRAL").Range("A" & SCrec))
    
            End If
        Next
    Last edited by arlu1201; 01-28-2014 at 02:33 PM. Reason: Use code tags in future.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] copy Tabs, based on two criteria in column J and paste values
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-13-2013, 03:46 PM
  2. Vba - find next empty column, insert column, copy paste values & copy paste formulas
    By DoodlesMama in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-20-2012, 12:43 PM
  3. [SOLVED] Macro to Copy Data and Paste Values Based on cell criteria
    By Taislin in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-16-2012, 06:51 PM
  4. paste RNG numbers
    By kaohik78 in forum Excel General
    Replies: 0
    Last Post: 09-26-2012, 10:30 PM
  5. Macro to copy and paste special values for column data and filter column data
    By ascottbag in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-10-2012, 02:15 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