+ Reply to Thread
Results 1 to 9 of 9

Counting number of non blank cells and inserting that amount on another sheet

  1. #1
    Forum Contributor
    Join Date
    10-12-2012
    Location
    Bournemouth
    MS-Off Ver
    Excel 2010 / Excel 2007
    Posts
    126

    Counting number of non blank cells and inserting that amount on another sheet

    Hi All

    I've been working on a bit of code to do as the title suggests, have tried a variety of things, but they all seem to be having the same affect.

    The basic overview is that throughout the month, a colleague will be inputting people to this system, and at the end of the month the data will be sent to our accounts department.

    The accounts team need a very specific form, which is fine and is set up - but by default I only want it to have a couple of lines where the employee details are entered, then when the macro is ran, I want it to count how many entries have been input throughout the month from the data capture sheet, and insert this amount of rows into the accounts sheet.

    I so far have the below code:

    Please Login or Register  to view this content.
    The code is unfinished at the end, as you may be able to see once inputting the rows, it goes back and copies the field, then inputs - this bit is fine, I just haven't got past this obstacle yet.

    The problem is, whilst the above affectively does what I want it to, it's inputting the wrong amount of lines. I have added and removed data from the Data Capture form to test, and regardless of there being 3 or 9 cells in "A" with data in, it inputs 19 rows each time!

    Anyone able to help with this at all? I have checked the cells and there is no hidden formula's/text or anything in them.

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Counting number of non blank cells and inserting that amount on another sheet

    Maybe you could try something along the lines of:
    Please Login or Register  to view this content.
    ?

  3. #3
    Forum Contributor
    Join Date
    10-12-2012
    Location
    Bournemouth
    MS-Off Ver
    Excel 2010 / Excel 2007
    Posts
    126

    Re: Counting number of non blank cells and inserting that amount on another sheet

    Hi Yudlugar

    That seems to work, but now encountering a bit of a problem with the formatting of the entered cells.

    Below is before and after running macro

    Before

    before.png

    After

    after.png

    Is there something I should possibly use other than
    Please Login or Register  to view this content.
    Thank you though for previous response - has got me a bit closer to the end of the tunnel =)

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Counting number of non blank cells and inserting that amount on another sheet

    Please can you upload your workbook with the full code, I can't tell at the moment.

  5. #5
    Forum Contributor
    Join Date
    10-12-2012
    Location
    Bournemouth
    MS-Off Ver
    Excel 2010 / Excel 2007
    Posts
    126

    Re: Counting number of non blank cells and inserting that amount on another sheet

    Hi

    Please see attached - thank you =)
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Counting number of non blank cells and inserting that amount on another sheet

    I'm not 100% sure it's what you want it to do but I think what you are looking for is:
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    10-12-2012
    Location
    Bournemouth
    MS-Off Ver
    Excel 2010 / Excel 2007
    Posts
    126

    Re: Counting number of non blank cells and inserting that amount on another sheet

    PERFECT. Thank you very much! The only issue I have now is that where I have 3 rows already there, it has 3 too many at the end, however as this is always going to be the case, changing the -2 at the end to -5 should fix this issue.

    Thanks again!

  8. #8
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Counting number of non blank cells and inserting that amount on another sheet

    I'd try something like:
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    10-12-2012
    Location
    Bournemouth
    MS-Off Ver
    Excel 2010 / Excel 2007
    Posts
    126

    Re: Counting number of non blank cells and inserting that amount on another sheet

    That's spot on - I did notice my -5 didn't work, it just messed up the formatting - your way does it great!

+ 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. counting the number of instances of blank cells in a range
    By moses67 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-01-2013, 10:35 AM
  2. [SOLVED] Inserting a specific number of blank rows between cells - Excel 2007
    By excelactuary in forum Excel General
    Replies: 3
    Last Post: 03-06-2013, 11:54 AM
  3. Counting number of non-blank cells for every nth cell
    By mqp92 in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 02-03-2013, 11:08 AM
  4. Finding Blank cells and inserting a number
    By skate1991 in forum Excel General
    Replies: 2
    Last Post: 02-14-2012, 07:22 AM
  5. Replies: 8
    Last Post: 07-23-2010, 02:28 PM

Tags for this Thread

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