+ Reply to Thread
Results 1 to 7 of 7

Testing a cell with an if statement to copy and paste text to another column.

  1. #1
    Registered User
    Join Date
    01-10-2014
    Location
    Nevada
    MS-Off Ver
    Excell 2007
    Posts
    9

    Testing a cell with an if statement to copy and paste text to another column.

    I feel kind of dumb because I can write this code in cobol, assembler and rpg but I am stumped here.

    A2 can be a number 1-16 and the cell is defined: =SUM(B2*1) I am only testing for 1 or 2.

    This is the macro code and as I step through it the IF statement executes but never recognizes A2 when it is equal to a 1 or a 2 so the copy and paste never happens. It looks quite simple but I can't get it to work. Can anyone please help me. Thanks.

    Please Login or Register  to view this content.
    Last edited by FDibbins; 01-10-2014 at 02:16 PM.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,917

    Re: Testing a cell with an if statement to copy and paste text to another column.

    Hi and welcome to the forum

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    I will add them for you - this time

    Also, why do you need a macro for this? You could just use =if(A2<=2,E2,"")
    (also, you could just use =B2*1, you dont need to use SUM() for that)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    01-10-2014
    Location
    Nevada
    MS-Off Ver
    Excell 2007
    Posts
    9

    Re: Testing a cell with an if statement to copy and paste text to another column.

    Ford, thanks for your help. I am getting the value of A2 from a '=RANDBETWEEN(1,16)' function in B2. Eventually I will be testing a range of 1 - 16 and copying and pasting into another sheet. The IF statements never execute the copy and paste when the values randomize to a 1 or a 2. It's like the value is not being recognized. What am I missing?

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,917

    Re: Testing a cell with an if statement to copy and paste text to another column.

    RANDBETWEEN() like any RANDOm() function, only triggers when something happens in the WB - like entering something, pressing F9 to calc etc

  5. #5
    Registered User
    Join Date
    01-10-2014
    Location
    Nevada
    MS-Off Ver
    Excell 2007
    Posts
    9

    Re: Testing a cell with an if statement to copy and paste text to another column.

    Yes =B2*1 works just as well and displays the value of the randbetween. The IF statement still does not recognize the value that is in cell A2?????
    Thanks

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,917

    Re: Testing a cell with an if statement to copy and paste text to another column.

    Try pressing F9

  7. #7
    Registered User
    Join Date
    01-10-2014
    Location
    Nevada
    MS-Off Ver
    Excell 2007
    Posts
    9

    Re: Testing a cell with an if statement to copy and paste text to another column.

    Thanks I set the break point within the if and it did not stop with the equal value.

+ 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. Copy paste into first cell in column, Skip cells with text.
    By miles.boyle in forum Excel General
    Replies: 4
    Last Post: 08-30-2013, 08:08 AM
  2. [SOLVED] Find text in column A then copy the cell to the right and paste it in sheet2
    By Alring in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-22-2013, 02:11 AM
  3. [SOLVED] Need MACRO to copy the text in the cell left of first selected cells (a column), paste all
    By joobeng in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-16-2013, 06:42 AM
  4. Testing for blank cells within Copy / Paste Array
    By MizM in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-30-2013, 11:39 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