+ Reply to Thread
Results 1 to 13 of 13

Coping range IF column has a value in it..almost got it

  1. #1
    Forum Contributor
    Join Date
    12-11-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    232

    Coping range IF column has a value in it..almost got it

    Cross-posted here too.
    http://www.mrexcel.com/forum/excel-q...9%25-done.html


    Please Login or Register  to view this content.
    In the range of F16:F30 there are two cells with the number 5 in it. I just want the code to grab each entire row and copy the rows to Sheet 2.

    This code grabs the line AFTER the last 5 in column F.

    Where is my error?

    I've Added a sample file to show the crazyness!

    Sample Macro.xlsm
    Last edited by nemo74; 03-07-2014 at 11:53 AM.

  2. #2
    Registered User
    Join Date
    04-20-2013
    Location
    Woking, England
    MS-Off Ver
    Excel 2003, Excel 2007
    Posts
    34

    Re: Coping range IF column has a value in it..almost got it

    Cross-posted here too :-
    http://www.mrexcel.com/forum/excel-q...9%25-done.html
    Mike

  3. #3
    Forum Contributor
    Join Date
    12-11-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    232

    Re: Coping range IF column has a value in it..almost got it

    **Removed disgruntled remark**
    Last edited by nemo74; 03-07-2014 at 11:28 AM.

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

    Re: Coping range IF column has a value in it..almost got it

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).
    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

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

    Re: Coping range IF column has a value in it..almost got it

    Try changing this line

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

  6. #6
    Forum Contributor
    Join Date
    12-11-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    232

    Re: Coping range IF column has a value in it..almost got it

    Thanks Alansidman,

    I understand now about the cross posting. I always post the results and close every thread on both forums if I do cross-post.

    I made the changes so the code now looks like
    Please Login or Register  to view this content.
    But it still is only coping the last row.

    I've uploaded a sample file to the first post.
    Last edited by nemo74; 03-07-2014 at 11:54 AM.

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

    Re: Coping range IF column has a value in it..almost got it

    I tested your code and it works for me. I am unable to replicate your issue.

  8. #8
    Forum Contributor
    Join Date
    12-11-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    232

    Re: Coping range IF column has a value in it..almost got it

    Really??

    When you use run it it copies

    Car red $50 $20 5
    Bike green $20 $5 2
    Plane white $100 $40 1

    in Sheet2 starting in A2?

    When I run my sample sheet I only get

    Plane white 100 40 1

    Even if I remove all values from Column F it still copies that last row to sheet2.

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

    Re: Coping range IF column has a value in it..almost got it

    I didn't see that you had attached a file. I tested it on my own file. Will try with your file.

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

    Re: Coping range IF column has a value in it..almost got it

    Ok. I got it figured. You are looking to post to the last row +1 in column A. Since there is nothing in column A, the macro is writing over the data into the same location - row2 which is the last row +1 in column A.

    Change it to look at column B for the last row.

    You would have seen this happen if you debugged your macro by stepping through the lines of code. If you are unsure about that, look at this video. He talks about debugging at about the 3 minute mark.

    Alan

  11. #11
    Forum Contributor
    Join Date
    12-11-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    232

    Re: Coping range IF column has a value in it..almost got it

    Thanks Alan, but I think you forgot the link to the video.

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

    Re: Coping range IF column has a value in it..almost got it


  13. #13
    Forum Contributor
    Join Date
    12-11-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    232

    Re: Coping range IF column has a value in it..almost got it

    Quote Originally Posted by alansidman View Post
    Ok. I got it figured. You are looking to post to the last row +1 in column A. Since there is nothing in column A, the macro is writing over the data into the same location - row2 which is the last row +1 in column A.

    Change it to look at column B for the last row.

    You would have seen this happen if you debugged your macro by stepping through the lines of code. If you are unsure about that, look at this video. He talks about debugging at about the 3 minute mark.

    Alan
    ok after doing some reading,debugging (thanks Alan), and moving some data around, I used

    Please Login or Register  to view this content.
    Thanks for the help 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. [SOLVED] Prvent Duplicates in Range A2:A100 while coping in to another sheet
    By vaibhav2312 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 08-21-2012, 09:22 AM
  2. coping a range into the next available empty cell in column "A"
    By joe dech in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-28-2011, 11:52 AM
  3. Coping cells based on dynamic range
    By acs013 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-17-2009, 08:44 AM
  4. Coping a range of cell values to the last row of another worksheet
    By BananaTang in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-19-2008, 01:07 PM
  5. coping data without coping formulars
    By stevekirk in forum Excel General
    Replies: 6
    Last Post: 09-07-2006, 11:47 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