+ Reply to Thread
Results 1 to 9 of 9

VBA code to copy specific cells based on cell value

  1. #1
    Forum Contributor
    Join Date
    05-06-2015
    Location
    Sri Lanka
    MS-Off Ver
    2016, 2007
    Posts
    135

    VBA code to copy specific cells based on cell value

    Hello, this is for learning purpose...Thanks in advance for any help

    I have 2 worksheets
    sheet 1 = "Original"
    sheet 2 = "Duplicate"

    in Original Sheet, I have data from A1 to E11
    I have only two values in the cells 0 and 1
    What I need to do is this

    Select A1 in Original Sheet
    Select All adjacent cells (all non blank cells)
    if in that range, in each cell value is 1
    then copy only those cells

    Go to Duplicate sheet
    paste those 1 in respective cells


    Can you help me to write a simple code for this? a sample data sheet is attached.
    Thanks again.
    Attached Files Attached Files

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs
    MS-Off Ver
    MS Office 365
    Posts
    20,201

    Re: VBA code to copy specific cells based on cell value

    What does your original sheet look like. You have only supplied us with the result sheet.

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    12,932

    Re: VBA code to copy specific cells based on cell value

    Here are two versions, move the 1's or clear the 0's

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    05-06-2015
    Location
    Sri Lanka
    MS-Off Ver
    2016, 2007
    Posts
    135

    Re: VBA code to copy specific cells based on cell value

    Quote Originally Posted by alansidman View Post
    What does your original sheet look like. You have only supplied us with the result sheet.
    Sheet Original is my "original"
    Duplicate is the result sheet.
    Thanks

  5. #5
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    12,932

    Re: VBA code to copy specific cells based on cell value

    Quote Originally Posted by Dineth View Post
    Sheet Original is my "original"
    Duplicate is the result sheet.
    Thanks
    I already supplied you with an answer Dineth

    @alansidman, the other sheet is there.

  6. #6
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs
    MS-Off Ver
    MS Office 365
    Posts
    20,201

    Re: VBA code to copy specific cells based on cell value

    Dave. Double checked. You are right. I missed it as it was to the left of the duplicate and I did not scroll to the left. Anyway, good response.

  7. #7
    Forum Contributor
    Join Date
    05-06-2015
    Location
    Sri Lanka
    MS-Off Ver
    2016, 2007
    Posts
    135

    Re: VBA code to copy specific cells based on cell value

    Quote Originally Posted by davesexcel View Post
    Here are two versions, move the 1's or clear the 0's

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Thank you very much

  8. #8
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs
    MS-Off Ver
    MS Office 365
    Posts
    20,201

    Re: VBA code to copy specific cells based on cell value

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  9. #9
    Forum Contributor
    Join Date
    05-06-2015
    Location
    Sri Lanka
    MS-Off Ver
    2016, 2007
    Posts
    135

    Re: VBA code to copy specific cells based on cell value

    OK. with respect can I keep it open for some more time? As this is me to learn Basics of VBA, I really like if someone have other options too...

    And originally, what I wanted to learn is doing copy and paste via VBA.

    Also, I wanted to see if I copy and paste it, and if I change the "wanted value" from 1 to 0, and if my duplicate already has 1s, will it remove 1s? or will it keep 1s and paste 0s too..?

    I am not sure if asking more questions in the same thread is illegal. If so I apologize.

+ 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. [SOLVED] Macro to copy specific data from one WB to specific cells in another WB based on specific
    By d_rose in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-26-2014, 11:05 AM
  2. Color code specific cells (on a per row bases) based on textual value within cell
    By Davey19 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 09-15-2013, 08:22 PM
  3. [SOLVED] Please help, problem VBA code to copy value to another specific sheet based on cell value
    By herukuncahyono in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-30-2013, 03:16 AM
  4. [SOLVED] Copy specific cells based on one word in the cell, to a different worksheet
    By Lfaulst1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-30-2013, 05:26 PM
  5. Replies: 0
    Last Post: 12-10-2012, 01:02 PM
  6. Code Problem Macro to copy specific cell based on the heading it is next to.
    By Mush1138 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-09-2011, 12:07 PM
  7. [SOLVED] how to color code a row of cells based on a specific cell value
    By Parker1333 in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 02-02-2005, 04: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