+ Reply to Thread
Results 1 to 17 of 17

Past a range of cells with a specified row width

  1. #1
    Forum Contributor
    Join Date
    04-07-2020
    Location
    New Zealand
    MS-Off Ver
    365
    Posts
    219

    Past a range of cells with a specified row width

    Hi,

    I have a code below that I did a macro recording on to copy a range of cells in a row directly below the copied row. I linked the code to a command button so that every time I click the command button it adds a new row. I cannot seem to extend on the code so that when copied, it copies it to a row height of 140. Also when copying, it narrows the Legend row cutting of some of the text. My code I'm using is

    Please Login or Register  to view this content.
    Last edited by AliGW; 04-10-2020 at 04:26 AM.

  2. #2
    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,417

    Re: Past a range of cells with a specified row width

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. As you are new, I'll do it for you this time.)

    I have moved this thread to the appropriate forum section.
    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.

  3. #3
    Forum Contributor
    Join Date
    04-07-2020
    Location
    New Zealand
    MS-Off Ver
    365
    Posts
    219

    Re: Past a range of cells with a specified row width

    Thank you for doing the tags for me. I have noted your previous comment on this and included the tag/s # before and # after

    I am not sure how this is done, apologies for that

  4. #4
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Past a range of cells with a specified row width

    Possibly adding this line to the end of your code
    Please Login or Register  to view this content.

  5. #5
    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,417

    Re: Past a range of cells with a specified row width

    I am not sure how this is done, apologies for that
    From the forum rule page:

    [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] (or use the # button)
    From my post above:

    Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here: http://www.excelforum.com/misc.php?do=bbcode

  6. #6
    Forum Contributor
    Join Date
    04-07-2020
    Location
    New Zealand
    MS-Off Ver
    365
    Posts
    219

    Re: Past a range of cells with a specified row width

    Thanks Dangelor

    I have placed that at the end however apologize, I should have mentioned that there are two rows from which i am copying, it is A 130 and A131

    it is only A 131 that should paste to 140, A 130 can remain at its current size/height

  7. #7
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Past a range of cells with a specified row width

    Try...
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    04-07-2020
    Location
    New Zealand
    MS-Off Ver
    365
    Posts
    219

    Re: Past a range of cells with a specified row width

    I have included a snippet of the column and row being copied below. All i basically want is that the code tells it to copy the rows at exactly the same height

    Attachment 671723

  9. #9
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Past a range of cells with a specified row width

    Your attachment isn't viewable. Post a workbook using the yellow highlighted instructions at the top of your original post.

  10. #10
    Forum Contributor
    Join Date
    04-07-2020
    Location
    New Zealand
    MS-Off Ver
    365
    Posts
    219

    Re: Past a range of cells with a specified row width

    I tried , it shuts down excel each time i make a copy to save of the workbook

    But its basically just

    A130 = 18 high
    A131 = 18 high
    A132 = 140 high

    When i copy these row ranges I would like them to be the same size when pasted. In my workbook they are linked to a command button, each time I click the button it creates a new entry row/s which is the sizes above

  11. #11
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Past a range of cells with a specified row width

    Unfortunatly, copy & pasted doesn't carry over the rows' height. Try
    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    04-07-2020
    Location
    New Zealand
    MS-Off Ver
    365
    Posts
    219

    Re: Past a range of cells with a specified row width

    Thanks Dangelor

    This works perfectly on the first button click however, when you and a second row (Copy of 13, 131, 132) it troughs a error message saying "there is already data in that range, do you want to replace it"

    I ran a debug and it highlights " ActiveSheet.Paste "

    Should that not change as it was not a normal copy paste function but rather specified heights ?

    fro example

    xlPasteFormats or a combination so that it copies the values and formulas as well ?

  13. #13
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Past a range of cells with a specified row width

    Try assigning the range to a variable using Application.Inputbox or reading it from some cell in the worksheet. If you need some help with that, let me know, but I'm offline in a bit tonight.

  14. #14
    Forum Contributor
    Join Date
    04-07-2020
    Location
    New Zealand
    MS-Off Ver
    365
    Posts
    219

    Re: Past a range of cells with a specified row width

    Thanks , Yeah I have no clue how to do that , a bit of a newbe to this coding process, will appreciate your help with this

    No worries when ever you have a moment or time, all good , thanks so far for everything

  15. #15
    Forum Contributor
    Join Date
    04-07-2020
    Location
    New Zealand
    MS-Off Ver
    365
    Posts
    219

    Re: Past a range of cells with a specified row width

    Hallo Dangelor

    Thank you for al your help. I have managed to find the problem. The problem was not in the code it was the fact that Cell A130 and A131 was merged. Once I un-merged the two cells it work perfectly fine

    Thank you once again !

  16. #16
    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,417

    Re: Past a range of cells with a specified row width

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  17. #17
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Past a range of cells with a specified row width

    Yeah, merged cells are a bane to good worksheets. Good luck!

+ 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] Range Continuing Past Last Row
    By Oxygen Potassium in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-27-2019, 07:12 PM
  2. Cut and Past Range of Row to another sheet
    By TheTallOne in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-30-2018, 09:00 PM
  3. [SOLVED] SUMIF formula with dynamic column range and then expand the width of SUM range
    By gravythief in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-26-2017, 08:36 AM
  4. Replies: 0
    Last Post: 07-24-2014, 09:11 AM
  5. [SOLVED] Cut & Past For Selected Range
    By hecgroups in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 03-26-2012, 11:03 AM
  6. Extending column width past 255 characters
    By shieldsty in forum Excel General
    Replies: 4
    Last Post: 09-26-2008, 07:56 AM
  7. Replies: 2
    Last Post: 09-16-2005, 07:05 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