+ Reply to Thread
Results 1 to 42 of 42

Add Row With Macro

  1. #1
    Forum Contributor
    Join Date
    07-31-2018
    Location
    London, England
    MS-Off Ver
    MS Office 365
    Posts
    104

    Add Row With Macro

    Hi Excel pros. I'm having a load of trouble with my basic macros.

    I have two buttons on a database whose code looks like this:

    Screen Shot 2018-08-06 at 11.23.39.png

    One for adding a row, one for deleting a row. The 'delete row' button works as it should.

    The 'add row' button, however, seems to struggle: When pressed, it adds a row before the last row when I want it to add a row after the last row. Additionally, I want it to create a row with a formula in the A column to increase the number by one:

    Screen Shot 2018-08-06 at 11.24.33.png

    Could someone suggest edits for my code to achieve this?

    Thanks in advance.
    Last edited by doubleuson; 08-07-2018 at 08:14 AM. Reason: SOLVED

  2. #2
    Forum Contributor
    Join Date
    09-21-2009
    Location
    Belgium - Mechelen
    MS-Off Ver
    Office 365 - version 2310
    Posts
    278

    Re: Add Row With Macro

    you could try :

    Please Login or Register  to view this content.
    i've added a small WB with the code.
    Attached Files Attached Files
    Last edited by MarMo; 08-06-2018 at 09:52 AM.
    Even a little help can be a big help !!
    1. A sample workbook says more then words. Add problem description and solution so we can understand the problem.
    2. Your appreciation is accepted by clicking the star "Add Reputation" at the lower left of the post.
    3. If your problem is solved, mark it as [SOLVED]: See "FAQ : " https://www.excelforum.com/faq.php
    4. Use [CODE] [/CODE] tags to illustrate your code: see here

  3. #3
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: Add Row With Macro

    or

    Please Login or Register  to view this content.

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,260

    Re: Add Row With Macro

    Just FYI, Shift:=x2Down should be Shift:=xlDown. (note that is a lower case L and not the number 1)

  5. #5
    Forum Contributor
    Join Date
    07-31-2018
    Location
    London, England
    MS-Off Ver
    MS Office 365
    Posts
    104

    Re: Add Row With Macro

    Quote Originally Posted by MarMo View Post
    you could try :

    Please Login or Register  to view this content.
    i've added a small WB with the code.
    I implemented a slightly adjusted (changing cell E to cell X) version of this code to my database and I got this error:

    Screen Shot 2018-08-06 at 15.02.44.png

    I, also, cannot open your WB due to some sort of unsupported Excel features. So I attached a copy of my workbook below, could you possibly reply with the code I can exactly copy and paste into the macro box for that button?

    Additionally, I need the new row to expand the active table, else the formulae on the other sheets will not adjust their range to the additional variables.

    Thanks.

  6. #6
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: Add Row With Macro

    There are more reactions

  7. #7
    Forum Contributor
    Join Date
    07-31-2018
    Location
    London, England
    MS-Off Ver
    MS Office 365
    Posts
    104

    Re: Add Row With Macro

    Quote Originally Posted by Vraag en antwoord View Post
    There are more reactions
    Hey Vraag, I entered your macro code into VBA and it came up with this error.

    Screen Shot 2018-08-06 at 16.37.19.png

  8. #8
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: Add Row With Macro

    The file does not match with the pictures. In which sheet can we search?

    Place a representative file and show how you applied the code

  9. #9
    Forum Contributor Neilesh Kumar's Avatar
    Join Date
    05-26-2016
    Location
    INDIA
    MS-Off Ver
    2013 & 2016
    Posts
    848

    Re: Add Row With Macro

    Hi doubleuson, Please find here attached the solution. I hope you are looking exactly the same.

    If the provided solution matches with your requirement then kindly mark thread as solved.

    Add Blank Row after last row.xlsb

  10. #10
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Add Row With Macro

    Hi doubleuson, I'm attaching two links that helped me when I was struggling with tables and named ranges.
    You probably won't have the time seen your Friday deadline but I can certainly advice is especially since your add and remove macros were from from correct
    https://www.thespreadsheetguru.com/b...t-excel-tables
    https://www.thespreadsheetguru.com/b...o-named-ranges

    Did you read the previous post with the macro code I posted for the updating of the formulas?
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  11. #11
    Forum Contributor
    Join Date
    07-31-2018
    Location
    London, England
    MS-Off Ver
    MS Office 365
    Posts
    104

    Re: Add Row With Macro

    Quote Originally Posted by Neilesh Kumar View Post
    Hi doubleuson, Please find here attached the solution. I hope you are looking exactly the same.

    If the provided solution matches with your requirement then kindly mark thread as solved.

    Attachment 585017
    Unfortunately, this formula simply crashes the spreadsheet. Additionally, were it to work, does it apply a new number in the A column which will be the previous A cell +1?

  12. #12
    Forum Contributor Neilesh Kumar's Avatar
    Join Date
    05-26-2016
    Location
    INDIA
    MS-Off Ver
    2013 & 2016
    Posts
    848

    Re: Add Row With Macro

    Hi doubleuson, It works quite fine at my end. Make sure macro settings are enabled. Please find here attached with the upgraded VBA where with the adding row the script will also provide the serial number in Column A.

    If the provided solution matches with your requirement then kindly mark thread as solved.

    Add Blank Row after last row.xlsb

  13. #13
    Forum Contributor
    Join Date
    07-31-2018
    Location
    London, England
    MS-Off Ver
    MS Office 365
    Posts
    104

    Re: Add Row With Macro

    The file you sent works, however, my attempts to import it into my current database do not. Here is my error message:

    Screen Shot 2018-08-07 at 11.07.32.png

  14. #14
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,260

    Re: Add Row With Macro

    I think you forgot to copy the SerialCode routine from module2 into your current workbook.

  15. #15
    Forum Contributor Neilesh Kumar's Avatar
    Join Date
    05-26-2016
    Location
    INDIA
    MS-Off Ver
    2013 & 2016
    Posts
    848

    Re: Add Row With Macro

    Hi doubleuson, In the attached sample workbook i have added two modules. So please insert another module and paste over there the script. It will certainly work.

  16. #16
    Forum Contributor
    Join Date
    07-31-2018
    Location
    London, England
    MS-Off Ver
    MS Office 365
    Posts
    104

    Re: Add Row With Macro

    Quote Originally Posted by rorya View Post
    I think you forgot to copy the SerialCode routine from module2 into your current workbook.
    I did, but having done so and created a Module2 within my database, it proceeded to crash the spreadsheet altogether.

    If I was better than slightly okay at doing this, we wouldn't be here...

  17. #17
    Forum Contributor Neilesh Kumar's Avatar
    Join Date
    05-26-2016
    Location
    INDIA
    MS-Off Ver
    2013 & 2016
    Posts
    848

    Re: Add Row With Macro

    Hi doubleuson, please find here attached the revised one where i have removed the module 2 and copied the module 2 script in module 1. I really surprised that it proceeded to crash where it works perfectly in my case.

    Please try the revised one and do let me know if it also proceeds to crash.

    Add Blank Row after last row.xlsb

  18. #18
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,413

    Re: Add Row With Macro

    @ Doubleuson

    It's not that you're not OK at it, it's just that you have taken on so much new learning in a short space of time. I think you over-promised a bit at work and are now in danger of under-delivering.

    To help things along here, you ought to attach your workbook. It will be easier to troubleshoot seeing what you have done in situ.
    Last edited by AliGW; 08-07-2018 at 07:20 AM.
    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.

  19. #19
    Forum Contributor Neilesh Kumar's Avatar
    Join Date
    05-26-2016
    Location
    INDIA
    MS-Off Ver
    2013 & 2016
    Posts
    848

    Re: Add Row With Macro

    Quote Originally Posted by AliGW View Post
    It's not that you're not OK at it, it's just that you have taken on so much new learning in a short space of time. I think you over-promised a bit at work and are now in danger of under-delivering.

    To help things along here, you ought to attach your workbook. It will be easier to troubleshoot seeing what you have done in situ.
    I do apologies Dear Expert. I will certainly take care henceforward.

  20. #20
    Forum Contributor
    Join Date
    07-31-2018
    Location
    London, England
    MS-Off Ver
    MS Office 365
    Posts
    104

    Re: Add Row With Macro

    Quote Originally Posted by Neilesh Kumar View Post
    I do apologies Dear Expert. I will certainly take care henceforward.
    I believe she is addressing me. You're doing well, I'm sure.

    Quote Originally Posted by AliGW View Post
    It's not that you're not OK at it, it's just that you have taken on so much new learning in a short space of time. I think you over-promised a bit at work and are now in danger of under-delivering.

    To help things along here, you ought to attach your workbook. It will be easier to troubleshoot seeing what you have done in situ.
    You are quite correct in that. I did not realise how difficult to implement something that seemed so intuitive was. I have no idea about pricing for projects.

    I thought I had attached my workbook earlier, but I have now, regardless.

    How much would you reckon it would cost to finish off my project?

  21. #21
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,413

    Re: Add Row With Macro

    Quote Originally Posted by Neilesh Kumar View Post
    I do apologies Dear Expert. I will certainly take care henceforward.
    Not aimed at you at all - sorry, should have made it clear.

  22. #22
    Forum Contributor
    Join Date
    07-31-2018
    Location
    London, England
    MS-Off Ver
    MS Office 365
    Posts
    104

    Re: Add Row With Macro

    Quote Originally Posted by Neilesh Kumar View Post
    Hi doubleuson, please find here attached the revised one where i have removed the module 2 and copied the module 2 script in module 1. I really surprised that it proceeded to crash where it works perfectly in my case.

    Please try the revised one and do let me know if it also proceeds to crash.

    Attachment 585126
    So this is my code, and it either insists SubAddRow() is not defined; or it crashes the entire document. I'm sure a small tweak will implement it.

    Screen Shot 2018-08-07 at 12.15.38.png

    Please see the post above for the workbook. If you could make it work in there, I would be greatly pleased.

    Copying your most recent code inclusive of the SerialCode causes the spreadsheet to crash. Can you try implementing it directly in my workbook and seeing what effect that has?
    Last edited by doubleuson; 08-07-2018 at 07:33 AM.

  23. #23
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,413

    Re: Add Row With Macro

    How much would you reckon it would cost to finish off my project?
    How much is it worth to you?

    I don't know, to be honest. There are at least three strands to it at the moment, and I'm not sure that it's entirely clear in any of them how much more there is to be done beyond what various helpers here are working on at the moment. As you have pretty full engagement at the moment, I would just dig in and see if you can get it done on a lot of goodwill.

    I would just counsel your not flying by the seat of your pants like this again.

  24. #24
    Forum Contributor
    Join Date
    07-31-2018
    Location
    London, England
    MS-Off Ver
    MS Office 365
    Posts
    104

    Re: Add Row With Macro

    I mean if the person with the most understanding of my requirements (which I do agree I have not been able to put into words so well), which is most likely Keeballah, wants to step up and implement the final work for a reasonable sum, I can go through the points system. I'm currently struggling to figure out how and where to implement the two macros and functions he/she wrote for me.
    Last edited by AliGW; 08-07-2018 at 07:47 AM.

  25. #25
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,413

    Re: Add Row With Macro

    I believe Keebellah said in one of your threads that they would be away for a couple of days now.

  26. #26
    Forum Contributor
    Join Date
    07-31-2018
    Location
    London, England
    MS-Off Ver
    MS Office 365
    Posts
    104

    Re: Add Row With Macro

    You're right. I just recall that now.

    It doesn't, to me, seem like what needs to be done is hugely difficult, so long as you understand what you are doing. How would I go about getting a quote for the remainder of the work?
    Last edited by AliGW; 08-07-2018 at 08:40 AM.

  27. #27
    Forum Contributor Neilesh Kumar's Avatar
    Join Date
    05-26-2016
    Location
    INDIA
    MS-Off Ver
    2013 & 2016
    Posts
    848

    Re: Add Row With Macro

    Hi doubleuson, Please try the attached. I feel i have fixed the crash in the revised one. Please do let me know if it further proceeds for crash.

    Request to you kindly do mark as Solved thread if it matches with your requirement.

    Proposed DA Learner Details (Hyperlink Edit).xlsb

  28. #28
    Forum Contributor
    Join Date
    07-31-2018
    Location
    London, England
    MS-Off Ver
    MS Office 365
    Posts
    104

    Re: Add Row With Macro

    Yep, that's resolved that issue. Thank you very much.

    /SOLVED

    Still have open issues, one significantly more complex than the others:

    https://www.excelforum.com/excel-for...ssistance.html

    https://www.excelforum.com/excel-for...le-sheets.html

    https://www.excelforum.com/excel-for...-criteria.html
    Last edited by AliGW; 08-07-2018 at 08:40 AM. Reason: Unnecessary quotations removed from several posts.

  29. #29
    Forum Contributor Neilesh Kumar's Avatar
    Join Date
    05-26-2016
    Location
    INDIA
    MS-Off Ver
    2013 & 2016
    Posts
    848

    Re: Add Row With Macro

    Glad to help Dear. Yeah certainly i would look into those since i am at work so probably by today night i would try to resolve them if i could able to do so.

  30. #30
    Forum Contributor
    Join Date
    07-31-2018
    Location
    London, England
    MS-Off Ver
    MS Office 365
    Posts
    104

    Re: Add Row With Macro

    I would very much appreciate the help, if you are proficient with VBA coding. Message me if you need any further clarification.
    Last edited by AliGW; 08-07-2018 at 08:39 AM.

  31. #31
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Add Row With Macro

    I’m indeed away but curiosity ... I can’t do much on my phone but will take a look tonight (Wednesday) after i’m home, no promises but hope i can help along

  32. #32
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Add Row With Macro

    Can you attach the most recent version of your file (again) if possible?
    So when I get home later this evening I at least know that that is your latest version.
    Your deadline is a serious issue for you but like I said I cannot guarantee anything except helping along where I can, and BTW I'm a he
    You also read @AliGW's and my comment of the other post.

  33. #33
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,413

    Re: Add Row With Macro

    I think the latest version of the workbook is being used here: https://www.excelforum.com/excel-for...le-sheets.html

  34. #34
    Forum Contributor
    Join Date
    07-31-2018
    Location
    London, England
    MS-Off Ver
    MS Office 365
    Posts
    104

    Re: Add Row With Macro

    I spoke to my boss and told them that I doubt I can get it all done by then. They'd rather it gets done well than get it done immediately, since it won't be used until the end of August anyway.

    I attached the newest version of the file to the post I made in the other thread we have been communicating on.

    I appreciate all and every bit of help provided, and will work with you at your convenience since, after all, this is non-commercial work.

  35. #35
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,413

    Re: Add Row With Macro

    I spoke to my boss and told them that I doubt I can get it all done by then.
    This made me snigger. I think you will need to include a credits tab in your workbook.

    Thank goodness the pressure's off for now!!! Lucky reprieve there.

  36. #36
    Forum Contributor
    Join Date
    07-31-2018
    Location
    London, England
    MS-Off Ver
    MS Office 365
    Posts
    104

    Re: Add Row With Macro

    Well I can't exactly admit I can't do it and tell them I've given it to someone else to do.

    A nice learning curve for a research intern.

    I am, however, more than willing to credit contributors in the workbook.

  37. #37
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,413

    Re: Add Row With Macro

    I think you MUST credit them! And not just because it would be dishonest not to: in practical terms, when and if something goes wrong or needs changing, or someone at work asks you how it works, you are going to have to admit you don't know.

  38. #38
    Forum Contributor
    Join Date
    07-31-2018
    Location
    London, England
    MS-Off Ver
    MS Office 365
    Posts
    104

    Re: Add Row With Macro

    I intend to, but how they choose to be credited is up to them (by fullname, username, etc). Especially with the macros, I have no issue with a dummy row being created into the code with an individual's credit/signature.

    With regards to diagnosing issues with it, well, I intend to study it in-depth (rather than just present it to them) to see how it works, however, chances are I'll be back on here when it has a problem.

  39. #39
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,906

    Re: Add Row With Macro

    Good to hear the pressure’s off a bit, i’ll Do my best and try also to include sufficient comments for you to be able to pickup on the vba.

  40. #40
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,413

    Re: Add Row With Macro

    I have to tell you, this is keeping me greatly amused (I'm not hard to please)!!!

    I have had help with a few snippets of VBA in the past, but even having studied them, I'm still no nearer understanding how they work. I think your chances of fully understanding the code that you've been gifted here by the end of August are fairly slim. I think you're being just a tad over-optimistic ... again!

    With the best will in the world, I think the chances of your being back here are pretty much 100%. Not that I think you aren't capable of learning it all - far from it - it's just going to take longer than a couple of weeks, that's all.

    I do hope your boss is pleased with it, anyway.

  41. #41
    Forum Contributor
    Join Date
    07-31-2018
    Location
    London, England
    MS-Off Ver
    MS Office 365
    Posts
    104

    Re: Add Row With Macro

    @Keebellah: Has anyone compared you with a Patron Saint of late?

    @AliGW: Yeah I have to be optimistic that everything will pan out, else I'd have to contemplate a change in profession.

  42. #42
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,413

    Re: Add Row With Macro

    LOL! LOL! and ROFL!!!!

+ 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. Replies: 5
    Last Post: 02-16-2018, 06:50 AM
  2. Replies: 8
    Last Post: 09-22-2017, 05:41 AM
  3. Excel formula bar to display the result of the formula , not the formula?
    By max_max in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-18-2016, 07:15 PM
  4. Replies: 11
    Last Post: 06-06-2014, 03:34 PM
  5. how to hide formula in formula box, view lookup result in formula box?
    By vengatvj in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-14-2013, 04:06 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