+ Reply to Thread
Results 1 to 6 of 6

Macro to use array to copy all rows to a new sheet if a cell is not blank not working

  1. #1
    Forum Contributor
    Join Date
    07-11-2010
    Location
    Minneapolis, USA
    MS-Off Ver
    Excel 2016
    Posts
    308

    Macro to use array to copy all rows to a new sheet if a cell is not blank not working

    I am trying to a use array to copy all rows to a new sheet if a cell is not blank.

    I know there are other methods to do this but was trying to get a better hand with arrays but am failing here

    Right now the code copies the header row multiple times and moves all the content

    Thanks for any help or insight


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

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro to use array to copy all rows to a new sheet if a cell is not blank not working

    myArray is copied until the end of the loop. What do you want to happen?

  3. #3
    Forum Contributor
    Join Date
    07-11-2010
    Location
    Minneapolis, USA
    MS-Off Ver
    Excel 2016
    Posts
    308

    Re: Macro to use array to copy all rows to a new sheet if a cell is not blank not working

    Hello AB33, I want to copy only rows to sheet "XXX" where cells in column D of sheet "NodeFiles" are NOT blank

    I add a sheet to Book1 to show what I am after

    Thank you
    Attached Files Attached Files

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Macro to use array to copy all rows to a new sheet if a cell is not blank not working

    Hello capson,

    You're macro needed a few changes. The main one was you were not testing if the cell in column "D" was empty. You had equals when you meant not equals.

    The second was you were failing to extract just the single row from the array. I have made the code changes needed so your macro functions correctly. If you have any questions, just ask me.

    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro to use array to copy all rows to a new sheet if a cell is not blank not working

    Try the attached.
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    07-11-2010
    Location
    Minneapolis, USA
    MS-Off Ver
    Excel 2016
    Posts
    308

    Re: Macro to use array to copy all rows to a new sheet if a cell is not blank not working

    AB33, Thank you

    Leith Ross, Thank you

    Both solutions work beautifully, I will study them both as the are slightly different.

+ 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. How to create a macro to insert blank rows and copy data into blank rows?
    By zodiack101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-29-2013, 01:18 PM
  2. macro to copy changing range to next blank cell in another sheet
    By d2whales in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-09-2013, 12:55 PM
  3. Macro to copy rows to another sheet, based on cell value
    By hampton06 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-03-2012, 04:40 AM
  4. Copy rows from master sheet to other sheets if certain cell in column is blank
    By nadiaraciti in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-29-2011, 02:05 AM
  5. Macro to copy rows from 1 sheet into the next blank row on a different sheet
    By kpratico in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-13-2010, 01:16 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