Results 1 to 11 of 11

assistance required copy macro not giving expected results to new sheet

Threaded View

  1. #1
    Forum Contributor
    Join Date
    02-11-2014
    Location
    mauritius
    MS-Off Ver
    MS365
    Posts
    1,142

    assistance required copy macro not giving expected results to new sheet

    Hi All

    Trying to copy specific column to another sheet but some columns need not to be copied but still being copied by the macro.

    Should start at A1 of the new sheet

    See attached of expected results

    Can anyone help

    
    
    Sub M1()
    
        Dim ws1     As Worksheet
        Dim ws2     As Worksheet
        
        Dim arr()   As Variant
        Dim var     As Variant
        Dim x       As Long
        
        Set ws1 = Sheets("corps")
        Set ws2 = Sheets("csv")
        
        With ws1
            For Each var In Array("A", "B", "C", "D", "H", "I", "K", "L", " M", "Q", "R", "S", "T", "W")
                x = .Range(CStr(var) & .Rows.Count).End(xlUp).Row
                arr = .Range(CStr(var) & 1).Resize(x).Value
                
                ws2.Range(CStr(var) & 1).Resize(UBound(arr, 1)).Value = arr
                Erase arr
            Next var
        End With
        
        Set ws1 = Nothing
        Set ws2 = Nothing
    
    End Sub
    Attached Files Attached Files
    Last edited by JEAN1972; 01-14-2017 at 11:30 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Create Table Style Macro Not Producing Expected Results
    By mcclanat in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-19-2015, 10:47 AM
  2. "IF" statement not giving expected results
    By khank in forum Excel General
    Replies: 6
    Last Post: 11-17-2010, 04:14 PM
  3. IF Formula not giving expected results.
    By fungus in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-17-2010, 02:10 PM
  4. Macro is not generating expected results.
    By Foxcan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-10-2009, 04:16 PM
  5. Sumproduct formula not giving expected results
    By Shocked in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 09-30-2008, 03:12 PM
  6. [SOLVED] Why isn't this macro giving me proper results?
    By Girish in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-09-2005, 02:05 PM
  7. [SOLVED] MACRO Assistance Required
    By Andrew Fletcher in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-31-2005, 09:06 AM

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