+ Reply to Thread
Results 1 to 12 of 12

Copy entire row in insert in the middle of a table.

  1. #1
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Copy entire row in insert in the middle of a table.

    Hello,

    I am having some issues with the attached file that I was hoping someone could help me with. You will see the file has four tenant types. I want to have a button for each type that says insert "type name". The code will highlight an entire row and insert it at the last blank row in that specific type section. For example. The types are Restaurants, Variety Stores, Outparcels and Anchors. If I want to add a Variety Store. I would click the button. It would copy a variety store row that is hidden and insert it in the variety store section of the table. I was messing around with the code below but it isn't working.

    Please Login or Register  to view this content.
    Any help would be greatly appreciated. Thanks!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Copy entire row in insert in the middle of a table.

    I think instead of Range("E19" & Rows.count) you probably want Range("E" & Rows.count). I think you might also want to insert it in the row after so you would need Range("E" & Rows.count).End(xlUp).Offset(1,0).Select

    Try something like:
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: Copy entire row in insert in the middle of a table.

    Thanks yudlugar. I get a debug when I run the code on the Range ("E19" & Rows.Count).End(xlUp).Offset(1,0).Insert Shift:=xlDown line of code.

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Copy entire row in insert in the middle of a table.

    Ha. I told you what to change then didn't do it. Delete the 19 part.

    Not sure how it works in later versions of excel but I have a feeling that you may also need to select the same amount of columns for what you are trying to insert as to what you copy. So if you copy the entire row, you need to select an entire row to insert it into. So you probably need:
    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy entire row in insert in the middle of a table.

    Please Login or Register  to view this content.

    Can not copy an entire row to column E, should be column A.

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Copy entire row in insert in the middle of a table.

    AB33, Agreed, I wasn't entirely sure what OP is trying to copy and where it should look, but I was working on it being the last row in column E being the one where the new row should be inserted. I think my code should work though because I'm using Rows(Range("E".... not Range(Range("E"...

  7. #7
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: Copy entire row in insert in the middle of a table.

    the code is working now but it isn't inserting the row in that specific section of the tables. It is inserting them after rows 113. I need it to copy the row 113 which I am going to move to hidden rows above once the code is working. Then go to the variety store section find the last blank row and insert it there (It would insert at row 18 in this case. Then if I ran it a second time it would insert at row 19 and so on. Right now it is inserting them in row 117.

  8. #8
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: Copy entire row in insert in the middle of a table.

    If you look at the file attached you will see the different sections. I want the user to be able to insert a row in within the different sections when they want to add a row for variety store or restaurant etc.

  9. #9
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Copy entire row in insert in the middle of a table.

    ok

    So you probably want something like this.
    Please Login or Register  to view this content.
    The problem now is that row 113 will change everytime you insert it and shift it down? You might be better copying instead?

  10. #10
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: Copy entire row in insert in the middle of a table.

    SAWEET!! That worked. Thanks yudlugar! what does yudlugar mean?

  11. #11
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Copy entire row in insert in the middle of a table.

    No problem, sorry it took a while. It has no meaning. It's a word I made up playing scrabble.

  12. #12
    Forum Contributor
    Join Date
    10-24-2012
    Location
    Chicago
    MS-Off Ver
    O365
    Posts
    311

    Re: Copy entire row in insert in the middle of a table.

    This is what I ended up with on the code

    Please Login or Register  to view this content.
    Thanks again. I did a named range instead of the cell reference because every time I inserted a row that cell reference would have needed to change and a direct cell reference in the code wouldn't allow for that.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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