+ Reply to Thread
Results 1 to 11 of 11

Code Optimization - Copy cells from one sheet to another - remove blank rows

  1. #1
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Code Optimization - Copy cells from one sheet to another - remove blank rows

    While I was able to get code to work and do what it is I am wanting, something tells me that there are much better ways to do what I am trying to accomplish?

    Essentially, I am wanting to copy the contents of cells from "ClientDB" BJ4:BK(lastrow), BN4:BO(lastrow) - and so on

    and then have those contents paste only into column A and B of the Birthdays tab. Essentially I want to be able to enter in the month (for example May) and have an auto Filter of everybody whose birthday is that month.

    To Copy the persons Name and DOB I am using:

    Please Login or Register  to view this content.
    And then to eliminate the blank rows I am using
    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Code Optimization - Copy cells from one sheet to another - remove blank rows

    Administrative Note:

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. No help to be offered until the link is provided.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Code Optimization - Copy cells from one sheet to another - remove blank rows

    Solution available when Moderator's request has been complied with

  4. #4
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Re: Code Optimization - Copy cells from one sheet to another - remove blank rows

    Good Morning. I am so sorry... I had no idea it was a violation of the TOS... and will not do it again. Historically I have posted in different forums just so that I can learn different ways of accomplishing the same end goal. I have no formal training in VBA... and am learning it as I go. This project that I have taken on while it WAS way above my knowledge base has helped me grow a lot, and learn a lot as well.

    The link to the other post that I had is https://www.mrexcel.com/forum/excel-...ml#post5270398

    Again, please accept my apologies.

  5. #5
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Code Optimization - Copy cells from one sheet to another - remove blank rows

    Hi there,

    The attached version of your workbook contains some dummy values for Child Names and Dates Of Birth, and uses the following code to update the Birthdays worksheet:

    Please Login or Register  to view this content.
    The highlighted values may be altered to cater for changes to your worksheet names and/or layouts.

    The Birthdays worksheet contains buttons for updating and clearing the Birthdays list.


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Attached Files Attached Files

  6. #6
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Re: Code Optimization - Copy cells from one sheet to another - remove blank rows

    WOW! I will dig into this and let you know if I have any questions.

    Out of curiosity, is this something that you had previously done (or similarly done previously)? How the heck did you get all of this that quick?

  7. #7
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Code Optimization - Copy cells from one sheet to another - remove blank rows

    Hi again,

    Many thanks for your very prompt feedback.

    I didn't have anything specific already written, but I've done quite a few variations on Copy And Paste applications, and although yours was a bit different (twelve non-contiguous data ranges), I just approached your project along a "well-trodden pathway"

    Regards,

    Greg M


    P. S. Many thanks for the Reputation increase - much appreciated!
    Last edited by Greg M; 05-03-2019 at 07:38 AM. Reason: P. S. added

  8. #8
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Re: Code Optimization - Copy cells from one sheet to another - remove blank rows

    Hi Greg,

    I am seeing a bug and hoping that you can help out with it??? i suspect that it is coming from the "age" calculations that are
    happening

    If there is NO DOB listed for a child, then there cannot be an age for the child... right?

    But when the data is adding itself over to the "birthdays" tab, January is getting added in to the "Months" location
    Attached Files Attached Files

  9. #9
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: Code Optimization - Copy cells from one sheet to another - remove blank rows

    Hi again,

    Most of the "Full Name Child nn" cells appear to be empty, but they actually contain blank (space) values - clear these cells and the "UpdateBirthdays" routine will display the result you expect.

    Hope this helps - as always, please let me know how you get on.

    Regards,

    Greg M

  10. #10
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Re: Code Optimization - Copy cells from one sheet to another - remove blank rows

    Good Afternoon.

    Was hoping that you could help me figure out an error that is coming up?

    Something is happening around line 257 that is causing this...


    "Unable to get the YearFrac property of the Worksheet Function class"

    Please Login or Register  to view this content.


    Your thoughts???
    Attached Files Attached Files

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,719

    Re: Code Optimization - Copy cells from one sheet to another - remove blank rows

    Snuffnchess - is the data in these shared workbooks real or fake? If it is real, then you are breaking client confidentiality by posting them here. I expect this will also contravene your company policy on data protection.

    I have already removed what appears to be sensitive data from your other thread and explained why. I strongly suggest you remove these workbooks and replace them with desensitised sample data instead.

+ 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. VBA code remove blank rows from all tables
    By AlmaD in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-13-2018, 08:03 AM
  2. VBA code - copy info from sheet 1 to sheet 2 but NOT COPY BLANK CELLS
    By Yossarian1980 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-14-2017, 06:09 PM
  3. [SOLVED] Update existing VBA code - Remove blank rows
    By Tapyr in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-10-2016, 10:41 AM
  4. [SOLVED] help finish/fix this code: copy non-blank cells to corresponding cell on another sheet
    By Rerock in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-14-2016, 01:38 PM
  5. Replies: 5
    Last Post: 12-12-2013, 02:53 PM
  6. [SOLVED] VB code help- need copy cells in a row and paste to new sheet on next available blank line
    By Barbara Excel in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 11-27-2012, 03:11 PM
  7. VBA code to remove rows in case of blank cells
    By GrahamRoss in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-01-2011, 12:02 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