+ Reply to Thread
Results 1 to 6 of 6

Possible to have macro add new partial row with a specific column range on any clicked row

  1. #1
    Forum Contributor
    Join Date
    05-19-2012
    Location
    houston
    MS-Off Ver
    excel 2013
    Posts
    103

    Possible to have macro add new partial row with a specific column range on any clicked row

    Hi,

    I've currently been using a button to run the macro below to add an entire new row that keeps formulas and clears out entered data by selecting any cell and hitting the button. I'm working on another file now that will have data in columns A,B,C, D, and E that can't be changed or move down (data has to stay in it's current cells) so the current macro won't work as it moves the entire row down which would break the data in those columns.

    Starting in cell F5 data will be added through AF5 and continue down each row indefinitely. I've been trying to modify this macro (with of course no luck) to have it do the same add new row function when selecting any cell from F5 and down but only add a partial row starting at column F and going across not effecting the information in columns A,B,C, D, and E.

    Another aspect that is needed with the add row macro is for the new row to be inserted at the same place on 5 out of 10 sheets in the workbook. The current macro will add the row to multiple sheets if I group the sheets prior to running the macro, but I need the rows added to the different sheets without having to manually group the sheets first.

    Hope I've explained it clear enough. Not sure if this is even possible, but if it is help pointing me in the right direction for a solution would be greatly appreciated... I've come up empty so far.

    Please Login or Register  to view this content.
    Thank you!

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Possible to have macro add new partial row with a specific column range on any clicked

    Change the names of the 5 sheets to suit. You won't have to group the sheets.


    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    05-19-2012
    Location
    houston
    MS-Off Ver
    excel 2013
    Posts
    103

    Re: Possible to have macro add new partial row with a specific column range on any clicked

    AlphaFrog thank you! That works great when the sheets are unprotected, but I forgot to say they are protected (all with the same password).

    I was using the following code in ThisWorkbook module...

    Please Login or Register  to view this content.
    When i run the macro with the sheets protected it gives a debug error here....

    image.jpg


    Any ideas on how to or the best way to run it with the sheets protected?


    Also I have another button to delete a row, that only deletes the one selected row but need it to delete the same row on the 5 sheets now. Hacking up your add row macro code I came up with below, it deletes the row on the first sheet then gives a run-time error '9' Subscript out of range.... not sure where to go from there?

    Please Login or Register  to view this content.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Possible to have macro add new partial row with a specific column range on any clicked

    Have the code unprotect\reprotect each sheet...

    Please Login or Register  to view this content.

    add doesn't seem like the right name for a macro that deletes one row...

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    05-19-2012
    Location
    houston
    MS-Off Ver
    excel 2013
    Posts
    103

    Re: Possible to have macro add new partial row with a specific column range on any clicked

    Thank you AlphaFrog! haha yes add didn't make sense, it should have been delete I missed changing it.

    Both macros work almost perfectly... but for some reason the both stop on sheet4 once the macro has run correctly through sheet 5 and do not return to the original sheet and cell.

    The add row macro did return to the original sheet/cell before the protection code was added. Do I need to add something extra now with the protection to end on the original sheet and starting cell?

    Thank you again for all your help.

  6. #6
    Forum Contributor
    Join Date
    05-19-2012
    Location
    houston
    MS-Off Ver
    excel 2013
    Posts
    103

    Re: Possible to have macro add new partial row with a specific column range on any clicked

    Figured it out. Thanks again AlphaFrog!

+ 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: 0
    Last Post: 08-17-2017, 11:26 AM
  2. [SOLVED] Macro for specific column for specific date range
    By romandotcom in forum Excel General
    Replies: 2
    Last Post: 02-03-2016, 08:51 AM
  3. Copy range to specific column with specific date with macro
    By SEERC in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-29-2015, 03:09 AM
  4. Replies: 2
    Last Post: 08-02-2013, 08:04 AM
  5. [SOLVED] Select column A's cell in relation to the row that macro button was clicked on?
    By xlyfe in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-09-2013, 12:24 PM
  6. How do I make my macro insert/paste code in specific column range?
    By Rabbitstew in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-17-2012, 04:33 PM
  7. Macro to start automatically when cell in particular column is clicked.
    By Jaki in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-19-2012, 02:31 AM

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