+ Reply to Thread
Results 1 to 13 of 13

Copy Cells In One Column Based On Criteria In Another Column

  1. #1
    Registered User
    Join Date
    05-09-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    14

    Copy Cells In One Column Based On Criteria In Another Column

    Hi all,

    Could you please help me with the macro for this task, see attached fil.

    I want to copy the values in column B based on the value of column C (1, 2, and 3) into three separated columns in another sheet (i.e., Red = 1, Yellow = 2, and Green = 3).

    Thank you very much.

    Best,
    t
    Attached Files Attached Files

  2. #2
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Copy Cells In One Column Based On Criteria In Another Column

    Put the macro i your module1. you did mean columns 3 & 4 right?


    Please Login or Register  to view this content.
    Attached Files Attached Files
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  3. #3
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: Copy Cells In One Column Based On Criteria In Another Column

    Check if this is what you want:
    Please Login or Register  to view this content.
    Just note that I changed the following:
    I want to copy the values in column B based on the value of column C (1, 2, and 3) into three separated columns in another sheet (i.e., Red = 1, Yellow = 2, and Green = 3).
    to copying the values in column C based on the value of column D, because of the way your sample workbook was. You can change that to meet your original request by changing the 4 in red to a 3 and all the 3s in blue to 2.
    .?*??)
    `?.???.?*??)?.?*?)
    (?.?? (?.?
    Pichingualas <---
    ??????????????????????????

    Wrap your code with CODE TAGS.
    Thank those who helped you, Don't forget to add to their REPUTATION!!! (click on the star below their post).
    Please mark your threads as [SOLVED] when they are (Thread Tools->Mark thread as Solved).

  4. #4
    Registered User
    Join Date
    05-09-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Copy Cells In One Column Based On Criteria In Another Column

    Thanks GeneralDisarray and Pichingualas.

    Yes, I meant collum 3(C) and 4(D).

    Both codes work great for me. However, I have another function (i.e., scroll bar) that change the value of column 4(D) in real time. I found that every time I run the code, the macro adds values (to the columns Red, Yellow, and Green) rather delete the previous values and copy the new ones to the columns.

    Is there a way to do this? Thanks a lot again.

    t

  5. #5
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: Copy Cells In One Column Based On Criteria In Another Column

    This should do it:
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    05-09-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Copy Cells In One Column Based On Criteria In Another Column

    Awesome. Thanks Pichingualas.

    Sorry for asking a lot but Is there a way that I can automate this macro so that every time I change the value from the scroll bar, there worksheet update itself automatically?

  7. #7
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: Copy Cells In One Column Based On Criteria In Another Column

    You can call this macro at the end of the code of the other one. I think that's the best approach for what you want. Just type "Call TryWithThis" at the end of your other macro.

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    05-09-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Copy Cells In One Column Based On Criteria In Another Column

    Hi Pichingualas,

    I am using two Active X Controls Toolbars to change column D (1, 2, and 3). I linked the macro with the following code but it does not work. Please let me know what is wrong with this code. Thanks

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: Copy Cells In One Column Based On Criteria In Another Column

    Make TryWithThis a Public macro:

    Please Login or Register  to view this content.
    I think that should be it.

  10. #10
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: Copy Cells In One Column Based On Criteria In Another Column

    I mean, change the first line of the TryWithThis macro to what I typed in the previous post.

  11. #11
    Registered User
    Join Date
    05-09-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Copy Cells In One Column Based On Criteria In Another Column

    Awesome. Thank you so very much!

  12. #12
    Forum Contributor
    Join Date
    02-07-2012
    Location
    MIA
    MS-Off Ver
    Excel 2007, 2010
    Posts
    429

    Re: Copy Cells In One Column Based On Criteria In Another Column

    Glad to help

  13. #13
    Registered User
    Join Date
    05-09-2012
    Location
    Philippines
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: Copy Cells In One Column Based On Criteria In Another Column

    Quote Originally Posted by Pichingualas View Post
    I mean, change the first line of the TryWithThis macro to what I typed in the previous post.
    Yeap. After working with these code for sometime, I learned something

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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