+ Reply to Thread
Results 1 to 12 of 12

Button Function to Produce New Rows

  1. #1
    Registered User
    Join Date
    01-11-2016
    Location
    London, England
    MS-Off Ver
    Microsoft Office 2013
    Posts
    5

    Button Function to Produce New Rows

    G’day,

    My first post, here goes – I’m fairly new to learning VBA so any help at all on the following would be greatly appreciated.

    I was curious how it’s possible to create a spreadsheet which has two functions…curious as I hoped to use a spreadsheet with the function:

    A button at the top of the spreadsheet which adds a new sequential number to the next available row (I can do this part, but am struggling with the following part)…I would then like the numbered sequence to be inserted from a specific location i.e. set the first number to Column C, Row 10.
    Then, each time the button is clicked, it will insert a new row (i.e. Column C, Row 11). As the new row is inserted, the cells will all be populated with a defined set of data i.e. a check box which triggers a count of adding 13, and a count formula for another cell.

    Any help to support pulling the spreadsheet together would be greatly appreciated.

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Button Function to Produce New Rows

    an example file would help clarify exactly what you are after

    To Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    01-11-2016
    Location
    London, England
    MS-Off Ver
    Microsoft Office 2013
    Posts
    5

    Re: Button Function to Produce New Rows

    Thanks for your reply - I've attached the spreadsheet example here.

    Tab 1 is the before; tab 2 demonstrating the after.

    Thank you for any help you're happy to provide.Test Function.xlsx

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Button Function to Produce New Rows

    The approach I generally adopt for stuff like this is to keep a master row of formulae/constants above my data - in the example attached on row 2 which you can of course hide. I've named A2:F6 'NewRow' and created a simple macro

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Button Function to Produce New Rows

    your numbering system is a bit of a curve ball to work around

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

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Button Function to Produce New Rows

    ...sorry I forgot to attach the file I used. This contains the code I gave in post #4 and it includes the newrow range name.

    Notice how I've used cell formatting to to show the end ')' character. This means the cell value is a numeric and not text - as it would be if it showed '1)'
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    01-11-2016
    Location
    London, England
    MS-Off Ver
    Microsoft Office 2013
    Posts
    5

    Re: Button Function to Produce New Rows

    Hi Richard/ humdingaling,

    Thank you both for you're help; I'm afraid Richard I can't get your macro to function, an error seems to display.

    Humdingaling, thank you I'm able to run the macro and it works perfectly. The only issue is I can't seem to create a unique row function/ formula for cell Len count e.g. if the check box is True, then +13, if the check box is False +0.
    The formula I produce replicates the if True/ False formula for all check boxes (thus meaning when any check box is True, 13 is added to all rows.

    Are you happy to provide a little more support to help resolve this? I've tried a few ways around it but I think the bottom line is my knowledge is lacking to for an appropriate resolution - slowly but surely learning.

    Thank you for your time.

  8. #8
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Button Function to Produce New Rows

    Quote Originally Posted by Bargyy View Post
    Hi Richard/ humdingaling,

    Thank you both for you're help; I'm afraid Richard I can't get your macro to function, an error seems to display.

    What error message do you get? Are you running the macro by clicking the button and is the sheet unprotected.?
    It's a simple one line macro and there's no reason I can see why it won't work for you whereas it does for me.

  9. #9
    Registered User
    Join Date
    01-11-2016
    Location
    London, England
    MS-Off Ver
    Microsoft Office 2013
    Posts
    5

    Re: Button Function to Produce New Rows

    Quote Originally Posted by Richard Buttrey View Post
    What error message do you get? Are you running the macro by clicking the button and is the sheet unprotected.?
    It's a simple one line macro and there's no reason I can see why it won't work for you whereas it does for me.
    Hi Richard - it's working from the spreadsheet you've attached, so thank you for your help. Although, the function isn't available to uncheck the tick box to not add 13 (+13 if check box is true, add nothing if check box is False).

    Than kyou very much for your help.

  10. #10
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Button Function to Produce New Rows

    Hi,

    See attached. I missed the point about adding 13 although it's not clear of the 13 is added if the box is ticked or unticked.

    The attached avoids the use of tick boxes which can be a bit of a pane when you need to delete them since they don't delete when you delete a row. Instead I've used a 'BeforeDoubleClick' sheet macro.

    Double clicking a column D cell will alternately show a tick or blank - actually character "P" with a Windings2 font which shows as a tick. The formula in column C adds 13 if column D is a 'p'. If it should be the other way round then just adjust the C2 formula.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    01-11-2016
    Location
    London, England
    MS-Off Ver
    Microsoft Office 2013
    Posts
    5

    Re: Button Function to Produce New Rows

    Hi Richard, that's better than I had expected; thank you.

    From the macro you've run, I've tried to add 4 extra columns (E-F) to have no performed action/ no formulas attached other than a simple double click to show tick, and if double clicked again then remove tick based on the users needs.

    I've learnt from what has been done here and can use the macro to run the intended function on a separate spreadsheet, but when it comes to running the two together I find errors occur. I gather this is because two macros can't run separately, so I'm not sure how to pull them together.

    If you're happy to help on the last part of the spreadsheet please, could you advise how it may be done - I've attached the spreadsheet here so you can see what I mean if you are happy to help.

    Excel Test.xlsm

  12. #12
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Button Function to Produce New Rows

    Hi,

    Is the attached what you mean? I've commented out the code you put in since I didn't know what the reference to ChrW(&H2713) was attempting to do.
    Attached Files Attached Files

+ 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] if function to produce a value
    By jarett in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-08-2015, 01:30 PM
  2. Concatenate Multiple Rows to Produce Different String Combos?
    By boba7523 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-29-2015, 02:49 AM
  3. Making countif function produce blanks as opposed to 0's
    By njw499 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-16-2014, 10:28 PM
  4. macro to produce records reaches maximum rows
    By mrroling2000 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-10-2011, 05:51 PM
  5. function problem to produce data value with two condition of column
    By herukuncahyono in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-26-2010, 05:36 AM
  6. [SOLVED] Can IF function produce a blank cell?
    By [email protected] in forum Excel General
    Replies: 8
    Last Post: 02-27-2006, 01:35 PM
  7. produce a formulate to produce assigned seats for dinner
    By DavidJoss in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 10-03-2005, 10:05 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