+ Reply to Thread
Results 1 to 10 of 10

macro that will and copy rows only if data is in a cell

  1. #1
    Forum Contributor
    Join Date
    04-18-2009
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    161

    macro that will and copy rows only if data is in a cell

    I have a range that i need to run a report on regularly. This range has sporadic amounts of data in it. one time there may be 60 rows of data, next time there may be 250 rows of data. i want the macro to select and copy only the rows that have data in them.

    i currently have a macro that i just set a range A25:A400 so it goes down and copies all these rows so it covers me .... but it is causing me problems by copying all those empty rows.

    The macro will need to start at A25 and go down from there A26,A27 etc select and copy only rows that have data and stop. i need the data copied to a seperate sheet named "Combined Scoreboard" inputting at A25.

    Note: i only need to check to see if there is data in the A column cells starting at A25 and working down.

    Thanks
    Last edited by Traymond; 04-20-2009 at 12:51 PM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: macro that will and copy rows only if data is in a cell

    Do you have more than one column of data? If not, perhaps you could just sort and that would remove the blanks.

  3. #3
    Forum Contributor
    Join Date
    04-18-2009
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: macro that will and copy rows only if data is in a cell

    yeah , the macro sorts the column to remove blank rows. the problem i have is i never know how many rows down data will be so i can't set a firm range in the code.

    here is the current part of the code that it selects to copy

    Please Login or Register  to view this content.

    i have it going all the way down to 242 just to cover me in case i have that much data. i jut want the macro to select as far down as there is data... not always going all the way down to 242. sometimes i may only have data going down to say 99. I know the thought is so what if it is copying blank rows, but it is causing a problem i won't spend the time to explain. Thanks
    Last edited by VBA Noob; 04-20-2009 at 01:09 PM. Reason: Added code tags as per forum rules

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: macro that will and copy rows only if data is in a cell

    This should be some progress - it will find the last cell in col J with an entry - though it will copy any completely blank rows in between. Is it only if col A is blank that matters, or the whole of A to J?
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    04-18-2009
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: macro that will and copy rows only if data is in a cell

    It is only if colums A is blank .... I'll try this and see how it works. thanks

  6. #6
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: macro that will and copy rows only if data is in a cell

    Or maybe this. Not sure if it can be done in a simpler way, looks like it should but I haven't found it (yet).
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    04-18-2009
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: macro that will and copy rows only if data is in a cell

    Please Login or Register  to view this content.

    this is close ..... but it will copy a row if it finds data in any cell between A:J

    i need it to ignore a row if A is blank. Thanks
    Last edited by VBA Noob; 04-20-2009 at 01:10 PM.

  8. #8
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: macro that will and copy rows only if data is in a cell

    Try the revised code.

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: macro that will and copy rows only if data is in a cell

    Traymond,

    Please edit both of your posts to add code tags.
    Entia non sunt multiplicanda sine necessitate

  10. #10
    Forum Contributor
    Join Date
    04-18-2009
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    161

    Re: macro that will and copy rows only if data is in a cell

    I made it work by formatting my columns a little differently
    Thanks for the code.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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