+ Reply to Thread
Results 1 to 11 of 11

VBA- Paste starting in selected Row

  1. #1
    Registered User
    Join Date
    07-16-2012
    Location
    U.S
    MS-Off Ver
    Excel 2007
    Posts
    34

    VBA- Paste starting in selected Row

    Hi,

    I'm trying to get this to paste what I've copied starting in cell A30, rather than A1. I think it's the .End(xlUp).Row part, but I'm not sure what to change it to...

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: VBA- Paste starting in selected Row

    TRy this

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-17-2012
    Location
    Manama,Bahrain
    MS-Off Ver
    2003, 2007
    Posts
    71

    Re: VBA- Paste starting in selected Row

    Have you tried End(xlDown) instead of End(xlUp)

    End(xlUp) takes you to the relative topmost row in the area or region,
    which can be the bottomest row of the nearest populated area in the upward direction, if the cell area you are starting with is blank
    or the topmost row of the populated area in the upward direction, if the cell area you are starting with is within in the populated area.


    while End(xlDown) works in the same manner in the downward direction.

    ...in order to get the next available / empty cell or row at the bottom of the list, you should combine End(xlDown).Offset(1,0)
    Last edited by ChuckYeager; 07-18-2012 at 10:55 AM. Reason: spellings and omissions

  4. #4
    Registered User
    Join Date
    07-16-2012
    Location
    U.S
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: VBA- Paste starting in selected Row

    Fredlo- your solution would have worked, but it interfered with other parts of my code. For some reason, it would only paste one of the several copied worksheets.

    Chuck- Using the End(xlDown).Offset(1,0) code makes the next line of code (wsTarget.Range("A" & nTargetLastRow + 0).PasteSpecial) get caught up in debugging.

    At the point at which anything is pasted onto the spreadsheet, the spreadsheet is entirely empty, I need it to start pasting on A30

  5. #5
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: VBA- Paste starting in selected Row

    can you provide all the code?

    Try this changing the line

    Please Login or Register  to view this content.
    .

    with

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    07-16-2012
    Location
    U.S
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: VBA- Paste starting in selected Row

    That seemed to lead to the same result. Here is the full code of the sub leading up to the pasting section. With this code, it does copy/paste for all worksheets correctly, but it starts pasting on cell A1.

    Please Login or Register  to view this content.


    ---------- Post added at 11:10 AM ---------- Previous post was at 10:51 AM ----------

    If I change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    It starts pasting on A2, but it gets off track if I change it to + 30

    ---------- Post added at 11:17 AM ---------- Previous post was at 11:10 AM ----------

    Doh, got it. I had some formulas way down in the code that were still trying to act on the assumption that it was pasted in cell A1...Thanks for all your help, I learned a few tricks from it all

  7. #7
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: VBA- Paste starting in selected Row

    Try this, If it doesn't work. can you you atatche a copy of you workbook as well. So i can properly test it. I tried it with some dummy data and it works.

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    07-16-2012
    Location
    U.S
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: VBA- Paste starting in selected Row

    Success! Thanks again!!!

  9. #9
    Registered User
    Join Date
    07-17-2012
    Location
    Manama,Bahrain
    MS-Off Ver
    2003, 2007
    Posts
    71

    Re: VBA- Paste starting in selected Row

    I see you got the solution...and I get to learn about .Resize
    Last edited by ChuckYeager; 07-18-2012 at 12:47 PM. Reason: Editing response

  10. #10
    Valued Forum Contributor fredlo2010's Avatar
    Join Date
    07-04-2012
    Location
    Miami, United States
    MS-Off Ver
    Excel 365
    Posts
    762

    Re: VBA- Paste starting in selected Row

    I am glad it worked.

  11. #11
    Registered User
    Join Date
    07-16-2012
    Location
    U.S
    MS-Off Ver
    Excel 2007
    Posts
    34

    Re: VBA- Paste starting in selected Row

    Just realized an easy fix that would have solved it all- after it pasted into A1, I could have had it just insert 30 rows to push the data down

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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