+ Reply to Thread
Results 1 to 3 of 3

VBA: Copy certain columns from one sheet to another

  1. #1
    Registered User
    Join Date
    07-21-2004
    MS-Off Ver
    2010
    Posts
    51

    VBA: Copy certain columns from one sheet to another

    In "Sheet 1" I have data in columns A thru E.
    Based on Column E result ... If Column E = "Y", then I need to copy those rows, columns A thru D only, to "Sheet 2" starting in row 15
    Appreciate any help.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,232

    Re: Copy certain columns from one sheet to another

    You will need VBA for this - I shall move the thread for you.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    07-21-2004
    MS-Off Ver
    2010
    Posts
    51

    Re: Copy certain columns from one sheet to another

    Needing to copy rows of data (columns A,B,C,D) from one spreadsheet to another based on criteria in column E
    Here is what I have so far.
    This pulls in all data from columns A:E, I just need A:D & it's not pulling in all the rows.

    Sub CopyY()
    Dim c As Range
    Dim j As Integer
    Dim Source As Worksheet
    Dim Target As Worksheet

    ' Change worksheet designations as needed
    Set Source = ActiveWorkbook.Worksheets("Sheet 1")
    Set Target = ActiveWorkbook.Worksheets("Sheet 2")

    j = 15 ' Start copying to row 1 in target sheet
    For Each c In Source.Range("E1:E1000") ' Do 1000 rows
    If c = "Y" Then
    Source.Rows(c.Row).Copy Target.Rows(j)
    j = 15
    End If
    Next c
    End Sub
    Last edited by RSa; 11-12-2019 at 10:19 AM.

+ 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. Replies: 4
    Last Post: 08-03-2017, 04:31 PM
  2. Replies: 2
    Last Post: 04-16-2014, 07:19 PM
  3. [SOLVED] Copy columns from one sheet to next empty columns in another sheet
    By GavJ in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-10-2013, 07:08 PM
  4. Macro to copy 3 columns of data from multiple sheets into 3 columns on 1 sheet
    By bballdcm2007 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-15-2012, 04:37 PM
  5. [SOLVED] Seach for data from one sheet to another sheet and copy past adjacent columns
    By mahtabshaikh in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-19-2012, 10:19 AM
  6. [SOLVED] Copy multiple ranges / columns to 2 columns in sheet
    By constantmallee in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-14-2012, 04:24 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