+ Reply to Thread
Results 1 to 13 of 13

Copy cells data to another worksheet if statement is true

  1. #1
    Registered User
    Join Date
    08-24-2014
    Location
    Romania
    MS-Off Ver
    2013
    Posts
    18

    Copy cells data to another worksheet if statement is true

    Hello all,

    I have a small problem that is really annoying me and I don't know how to solve it.
    I have a bunch of rows in worksheet1 (starts from row 3 and goes down until 39) and each row has 15 columns.
    In cell 15 for each row I have a formula that checks if that specific row is good or not to be sent to the worksheet2 ( =IF(G7+1<L7;"Yes";"No") )
    If that formula gives Yes, then I need to copy Cell 1 , Cell 7 (but increment to value with +1) and Cell 13 to worksheet2 and put the in first free row.

    Cell 1 is Text format and Cell 7 has a formula in it so I need to copy the data and increment it with +1

    I have attached 1 picture for every sheet to it's easier to understand.
    Worksheet1.JPGworksheet2.JPG


    Thank you
    Last edited by Arthfael; 08-25-2014 at 10:40 AM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    23,971

    Re: Copy cells data to another worksheet if statement is true

    Hi and welcome to the forum

    Pictures are of little value. Honestly, no one wants to re-type your data to try and solve your issue. Additionally, we would only be guessing at how your data was structured, ie. formulas, formatting, etc.

    Please attach a sample file that represents what you have. The structure of your attachment should be the same structure as your actual data. Any proprietary information should be changed.

    Include in the attachment any code you're currently using (whether it works or not) and an "After" of what you wish the output to be.

    To attach a file to your post,
    click advanced (next to quick post),
    scroll down until you see "manage file",
    click that and select "add files" (top right corner).
    click "select files" find your file, click "open" click "upload" click 'done" bottom right. click "submit reply"

    Once the upload is completed the file name will appear below the input boxes in this window.
    You can then close the window to return to the new post screen.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    08-24-2014
    Location
    Romania
    MS-Off Ver
    2013
    Posts
    18

    Re: Copy cells data to another worksheet if statement is true

    Thanks for the reply

    Here is an example workbook with the same formulas that I am using in the original workbook and with what I want to do.

    VBA code that I managed to create but it's now working 100% :
    Please Login or Register  to view this content.
    And regarding what I want to do is this:
    The macro should loop through rows 3 to 10 and check Cell 15 ("Post Order?" column) to see if it's "YES"
    If the cell is "YES" for that specific row, then copy the ID, Count and Orders cell from that row and paste the values in Sheet2 in the first free row BUT incrementing the "Order" cell with +1
    Attached Files Attached Files

  4. #4
    Forum Contributor satputenandkumar0's Avatar
    Join Date
    11-08-2012
    Location
    Pune, India
    MS-Off Ver
    Office xp & Office 2007
    Posts
    398

    Re: Copy cells data to another worksheet if statement is true

    try below

    Please Login or Register  to view this content.
    (Late Reply due to net down)
    Regards,
    Nandkumar S.
    ---------------------------------------------------------------
    Don't forget to Click on * if you like my solution.

  5. #5
    Registered User
    Join Date
    08-24-2014
    Location
    Romania
    MS-Off Ver
    2013
    Posts
    18

    Re: Copy cells data to another worksheet if statement is true

    It works like a charm. Thank you

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy cells data to another worksheet if statement is true

    Maybe:

    Please Login or Register  to view this content.

  7. #7
    Forum Contributor satputenandkumar0's Avatar
    Join Date
    11-08-2012
    Location
    Pune, India
    MS-Off Ver
    Office xp & Office 2007
    Posts
    398

    Re: Copy cells data to another worksheet if statement is true

    Glad to help you

    Thanks JOHN H. DAVIS

  8. #8
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy cells data to another worksheet if statement is true

    Quote Originally Posted by satputenandkumar0 View Post
    Glad to help you

    Thanks JOHN H. DAVIS
    For what you just beat me to the punch.

  9. #9
    Forum Contributor satputenandkumar0's Avatar
    Join Date
    11-08-2012
    Location
    Pune, India
    MS-Off Ver
    Office xp & Office 2007
    Posts
    398

    Re: Copy cells data to another worksheet if statement is true

    @ JOHN H. DAVIS

    Sir,
    I learned from you another way (Use Range with rows.count)
    Last edited by satputenandkumar0; 08-25-2014 at 07:00 AM.

  10. #10
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    23,971

    Re: Copy cells data to another worksheet if statement is true

    Another Option:

    Please Login or Register  to view this content.
    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To run the Excel VBA code:
    1. Press Alt-F8 to open the macro list
    2. Select a macro in the list
    3. Click the Run button

  11. #11
    Registered User
    Join Date
    08-24-2014
    Location
    Romania
    MS-Off Ver
    2013
    Posts
    18

    Re: Copy cells data to another worksheet if statement is true

    Thank you everyone for the help

  12. #12
    Registered User
    Join Date
    08-24-2014
    Location
    Romania
    MS-Off Ver
    2013
    Posts
    18

    Re: Copy cells data to another worksheet if statement is true

    Quote Originally Posted by alansidman View Post
    Another Option:
    ....
    For some reason when I try your code, I get ID / Order / Count in Sheet2 and not ID / Count / Order.

  13. #13
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    23,971

    Re: Copy cells data to another worksheet if statement is true

    Yup! Now that you mention it, me, too. I am guessing that the Union function takes the order of the ranges in alpha sequence regardless of how they are arranged in the code.

    The good news is that you have two other solutions to work with.

    Thanks for pointing that issue out to me.

    Alan

+ 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: 1
    Last Post: 03-13-2013, 02:27 PM
  2. [SOLVED] If Statement to Copy Multiple Cells to Another Worksheet
    By cdh1234 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-08-2013, 03:01 PM
  3. Macro to Loop Through Cells and if the value is true, output data to another worksheet
    By clintonwarren in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-08-2012, 02:42 PM
  4. [SOLVED] Search range and copy cells to sheet2 if, if statement is true
    By pinstripe05 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-04-2012, 09:32 AM
  5. [SOLVED] If statement...copy values of cells on another worksheet.
    By heater in forum Excel General
    Replies: 2
    Last Post: 08-31-2005, 07:05 PM

Tags for this Thread

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