+ Reply to Thread
Results 1 to 13 of 13

Issue in Copying Row to a New Sheet

  1. #1
    Registered User
    Join Date
    11-30-2012
    Location
    North Carolina
    MS-Off Ver
    Office 365
    Posts
    60

    Issue in Copying Row to a New Sheet

    This appears to be a seemingly simple problem, but I cannot figure it out. Relative newbie to VBA, so any help would be appreciated.

    I have a form that copies data to a worksheet. Works fine. I would like to take the last row in that dynamic worksheet and copy to yet another worksheet, copying to a specific location (cell A250).. Everything works except that I cannot get the last row to copy to the destination worksheet. The error is clearly in the last line of code, as follows:

    Please Login or Register  to view this content.
    Can anyone troubleshoot this one?

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,750

    Re: Issue in Copying Row to a New Sheet

    That copies only one cell in column A, not the entire row. How many columns are you using? Try this, examples copies up to column Z

    Please Login or Register  to view this content.
    I believe this will work although it is possible the range sizes need to be the same, in which case

    Please Login or Register  to view this content.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Issue in Copying Row to a New Sheet


    Easy if data is really in first cell of last row :

    PHP Code: 
    Sub Demo1()
        
    With Worksheets("Info Data").UsedRange.Rows
            
    .Item(.Count).Cells(1).Copy Range("'Active X Controls'!A250")
        
    End With
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

  4. #4
    Registered User
    Join Date
    11-30-2012
    Location
    North Carolina
    MS-Off Ver
    Office 365
    Posts
    60

    Re: Issue in Copying Row to a New Sheet

    Sorry, neither one of those options worked.

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Issue in Copying Row to a New Sheet


    As it works on my side, you must crystal clear explain the issue and your need with an attachment !

    So data is not in last row for sure …
    Last edited by Marc L; 05-11-2017 at 10:08 PM.

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,750

    Re: Issue in Copying Row to a New Sheet

    Quote Originally Posted by lateniteNC1 View Post
    Sorry, neither one of those options worked.
    It will be much easier to understand your problem if you provide your file. This allows us to see and experiment with your data, layout, formulas, code, and possibly attach a file with a completed solution. If you are looking for formulas to produce a desired result, it helps if you create a mock-up of what you want the result to look like. Otherwise we would have to build something from scratch, trying to guess what you want it to look like.

    Under the text box where you type your reply click the Go Advanced button. On the next screen scroll down and click on Manage Attachments, which will show a pop-up window to Select and Upload a file. Then close the window and save the post.

  7. #7
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,098

    Re: Issue in Copying Row to a New Sheet

    Hello LateniteNC1,

    See if the following take on Jeff's code makes any difference:-
    Please Login or Register  to view this content.
    If not, then supply a sample as requested by Jeff and Marc.

    Cheerio,
    vcoolio.

  8. #8
    Registered User
    Join Date
    11-30-2012
    Location
    North Carolina
    MS-Off Ver
    Office 365
    Posts
    60

    Re: Issue in Copying Row to a New Sheet

    vcoolio:

    Your code did the trick; thank you.

    6StringJazzer:

    Thank you for your suggestion; as I originally thought it a fairly simple problem (the data WAS in the last row, with all cells filled in (no blanks)) and could be de-bugged without the file. In the future, I will most assuredly take your advice.

    Thanks to all who replied.

  9. #9
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,098

    Re: Issue in Copying Row to a New Sheet

    No worries Latenite. Glad that we were able to help.

    Cheerio,
    vcoolio.

  10. #10
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,750

    Re: Issue in Copying Row to a New Sheet

    My code should have been logically equivalent to vcoolio's but I see I made a small error.


    Please Login or Register  to view this content.

  11. #11
    Valued Forum Contributor
    Join Date
    06-29-2014
    Location
    Australia
    MS-Off Ver
    MSO 365
    Posts
    1,098

    Re: Issue in Copying Row to a New Sheet

    @ Jeff,

    Sorry Jeff. I should have checked properly before posting.

    Cheerio,
    vcoolio.

  12. #12
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,750

    Re: Issue in Copying Row to a New Sheet

    Quote Originally Posted by vcoolio View Post
    @ Jeff,

    Sorry Jeff. I should have checked properly before posting.

    Cheerio,
    vcoolio.
    No apology needed! It's always valuable to show more than one way to get to the same destination!

  13. #13
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Issue in Copying Row to a New Sheet


    For entire row, unlike initial code, just remove from my code .Cells(1) if really last row …

+ 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: 05-09-2017, 11:58 AM
  2. copying sheet issue caused by hidden sheets in fhile
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-19-2017, 10:37 AM
  3. Pattern Copying Issue
    By Sharkawy in forum Excel General
    Replies: 18
    Last Post: 10-24-2016, 04:13 AM
  4. Target Cell location issue while copying entire sheet by Macro
    By AnimeshRoy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-04-2016, 12:41 PM
  5. Copying Data from one sheet to another... issue using End(xldown) in subroutine
    By joe31623 in forum Excel Programming / VBA / Macros
    Replies: 37
    Last Post: 02-17-2016, 05:48 PM
  6. [SOLVED] Issue with Copying data to a New Sheet After Filtering.
    By AparnaSriram in forum Excel General
    Replies: 10
    Last Post: 11-16-2012, 04:17 AM
  7. Excel 2007 : issue copying sheet w/ names in calculations
    By BobbyD1120 in forum Excel General
    Replies: 3
    Last Post: 01-23-2011, 03:58 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