+ Reply to Thread
Results 1 to 11 of 11

VB to copy cell value in sheet1 to cells in sheet2 if criterion met

  1. #1
    Registered User
    Join Date
    12-05-2013
    Location
    Utah
    MS-Off Ver
    Excel 2013
    Posts
    31

    VB to copy cell value in sheet1 to cells in sheet2 if criterion met

    This following is just an example:

    In sheet1 I have 4 columns; Name, Age, *** and Job.

    Sheet2 has three columns; Name, Age and Job.

    What I need is VB that will check the *** column from Sheet1 and when it is Male, the Name, Age and Job fields from that row are copied into the cells in Sheet2.

    It's been a while since I've worked with VB and I am a bit rusty. Having a hard time figuring it out.

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: VB to copy cell value in sheet1 to cells in sheet2 if criterion met

    Try:
    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    12-05-2013
    Location
    Utah
    MS-Off Ver
    Excel 2013
    Posts
    31

    Re: VB to copy cell value in sheet1 to cells in sheet2 if criterion met

    Quote Originally Posted by Mumps1 View Post
    Try:
    Please Login or Register  to view this content.
    What is the best way to invoke it so that it doesn't copy itself over and over?

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: VB to copy cell value in sheet1 to cells in sheet2 if criterion met

    Assuming that Sheet2 has headers in the first row, try:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-05-2013
    Location
    Utah
    MS-Off Ver
    Excel 2013
    Posts
    31

    Re: VB to copy cell value in sheet1 to cells in sheet2 if criterion met

    Quote Originally Posted by Mumps1 View Post
    Assuming that Sheet2 has headers in the first row, try:
    Please Login or Register  to view this content.
    Works very well except when one of the cells is empty and then instead of leaving it empty on sheet2 it messes up the order

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: VB to copy cell value in sheet1 to cells in sheet2 if criterion met

    When you say that one of the cells is empty, do you mean one of the cells in column C? Could you post a copy of your file? This way it would be easier to see how your data is organized.

  7. #7
    Registered User
    Join Date
    12-05-2013
    Location
    Utah
    MS-Off Ver
    Excel 2013
    Posts
    31

    Re: VB to copy cell value in sheet1 to cells in sheet2 if criterion met

    Quote Originally Posted by Mumps1 View Post
    When you say that one of the cells is empty, do you mean one of the cells in column C? Could you post a copy of your file? This way it would be easier to see how your data is organized.
    test.xlsm


    I hope I attached the file correctly.

    In this example I have Age in column C. I didn't specify an age for a person named John. When I click the Report button it copies the cell data to Sheet2. However, it shows John with the age of the person below him.
    Attached Files Attached Files

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: VB to copy cell value in sheet1 to cells in sheet2 if criterion met

    OK. I have to go out now. I'll get back to you tomorrow morning.

  9. #9
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: VB to copy cell value in sheet1 to cells in sheet2 if criterion met

    Hi Cameron. Try the attached file.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    12-05-2013
    Location
    Utah
    MS-Off Ver
    Excel 2013
    Posts
    31

    Re: VB to copy cell value in sheet1 to cells in sheet2 if criterion met

    Quote Originally Posted by Mumps1 View Post
    Hi Cameron. Try the attached file.
    Works very well. I've modified it a bit to fit my needs.

    Thanks for your help.

  11. #11
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: VB to copy cell value in sheet1 to cells in sheet2 if criterion met

    My pleasure.

+ 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: 6
    Last Post: 07-25-2013, 02:58 PM
  2. [SOLVED] If cell value on Sheet1 not found on Sheet2 copy row to Sheet2
    By Yxx in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-18-2013, 04:15 AM
  3. Macro to copy range of cell from sheet1 to sheet2 based on a cell value in sheet2
    By drgwhizz in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-25-2012, 10:39 AM
  4. Copy 3 cells from sheet1 then paste to sheet2
    By Christeen in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-10-2011, 09:16 AM
  5. IF Sheet1 Cell A2 = value, THEN copy Sheet1 Row 2 to Sheet2 Row 2....?
    By dan1980 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-21-2009, 10:28 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