+ Reply to Thread
Results 1 to 15 of 15

VBA copy row bellow: values and formatting in Specific Range

  1. #1
    Registered User
    Join Date
    02-01-2017
    Location
    Lisboa
    MS-Off Ver
    2010
    Posts
    81

    VBA copy row bellow: values and formatting in Specific Range

    Hello,

    I have a worksheet with a table with data information on the the following columns A:G. I need to assign a macro to a button that do the following events: once the user select a row (or a cell) and click the button, the macro inserts a new row bellow the selected row with the same values, formulas and formats but only from de columns A:D, in the columns E:G the macro only copy the formulas and formats (in this columns the row appears without values).

    Is that possible?

    Thank you in advanced!

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA copy row bellow: values and formatting in Specific Range

    A regular copy-insert will do that
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    02-01-2017
    Location
    Lisboa
    MS-Off Ver
    2010
    Posts
    81

    Re: VBA copy row bellow: values and formatting in Specific Range

    Hello,

    I do not understand how a regular copy insert will do that I intend...I have a worksheet where some users have to insert daily information in one table and I need to avoid that some mistakes happening. A regular copy insert is what they are doing in this moment and clearly is not working...
    Thank you for your help anyway

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA copy row bellow: values and formatting in Specific Range

    After the regular copy-insert the F9 key must be pressed to refresh the calculations.

  5. #5
    Registered User
    Join Date
    02-01-2017
    Location
    Lisboa
    MS-Off Ver
    2010
    Posts
    81

    Re: VBA copy row bellow: values and formatting in Specific Range

    Hello,

    Ok, so after doing a regular copy-insert of the row above (and pressing the F9!), the cells of columns A:D will appear with the same information (values) and formulas of the above row and the cells of the columns E:G will appear only with the formulas..is not working....

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA copy row bellow: values and formatting in Specific Range

    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 then scroll down to Manage Attachments to open the upload window.

  7. #7
    Registered User
    Join Date
    02-01-2017
    Location
    Lisboa
    MS-Off Ver
    2010
    Posts
    81

    Re: VBA copy row bellow: values and formatting in Specific Range

    Hello,

    I send you one sample workbook with a BEFORE sheet and an AFTER.

    Thank you for your help.
    Attached Files Attached Files

  8. #8
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA copy row bellow: values and formatting in Specific Range

    This works:

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    02-01-2017
    Location
    Lisboa
    MS-Off Ver
    2010
    Posts
    81

    Re: VBA copy row bellow: values and formatting in Specific Range

    Hello,

    Thank you for sending me the new code, I replaced the macro by the one you sent me and it was exactly what I ask for but after doing some tests I realize that I did not thought in one situation:

    In some cases the users after insert the new row need to insert other rows and, I am sure that instead of selecting the first row (with values A:G) they are going to select the last row they had inserted (with values A:D and without values only with formulas in E:G).
    When we select a row that does not have values in columns E:G (only the formula in column G) and we click insert row, an error occurs in the VBA code...

    Is possible to overcome this situation? Thank you for all the help...

    In this moment I am doing Cross-posted : https://www.mrexcel.com/forum/excel-...fic-range.html because I have some urgency in finding the solution.
    Last edited by PaulaGon; 03-19-2018 at 10:04 AM.

  10. #10
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: VBA copy row bellow: values and formatting in Specific Range

    Cross-posted : https://www.mrexcel.com/forum/excel-...fic-range.html

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

  11. #11
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA copy row bellow: values and formatting in Specific Range

    I don't often use this Error code but try this:

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    02-01-2017
    Location
    Lisboa
    MS-Off Ver
    2010
    Posts
    81

    Re: VBA copy row bellow: values and formatting in Specific Range

    Hello,

    Thank you this code is working!

    Only one more doubt...it is possible instead of ussing a command button to run the macro, to made a double click in the cell of column A to insert the row? I think this would be best for the users ..

    Thank you in advanced!

  13. #13
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA copy row bellow: values and formatting in Specific Range

    Sure - put this code in the sheet module:

    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    02-01-2017
    Location
    Lisboa
    MS-Off Ver
    2010
    Posts
    81

    Re: VBA copy row bellow: values and formatting in Specific Range

    Hello,

    At first the code was running ok... but now it keeps appering the following message:"Method Insert of Object Range failed)" and Excel stop running

    When I click two times to insert rows or when a put a filter in the table and then click in a cell in column A to insert a row...the message appears and Excel stops running

    I do not understand why this is happening..
    Attached Files Attached Files

  15. #15
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: VBA copy row bellow: values and formatting in Specific Range

    It doesn't fail for me

+ 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 Copy specific Range with values to new worksheet with name based cell
    By PaulaGon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-13-2018, 12:44 PM
  2. [SOLVED] copy value from Tb in the next empty cell bellow...
    By Hovoruha Octavian in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-25-2016, 11:36 AM
  3. [SOLVED] Conditional formatting for duplicate values within a specific number range 2010
    By Nunzio in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 07-20-2014, 04:00 PM
  4. [SOLVED] Copy and paste range as values to specific sheet/range
    By lukestkd in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-06-2014, 09:48 PM
  5. [SOLVED] Copy range values without copying the formatting
    By JimDandy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2013, 08:13 AM
  6. Pick, copy and paste rows containing specific range of values
    By Kenneyd71 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-20-2012, 09:44 AM
  7. Copy a range WITH formatting and values
    By janschepens in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-09-2012, 04:46 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