Consulting

Results 1 to 14 of 14

Thread: Solved: copy the first row on sheet to lastest blank row of another Sheet .

  1. #1
    VBAX Mentor
    Joined
    Feb 2012
    Posts
    406
    Location

    Solved: copy the first row on sheet to lastest blank row of another Sheet .

    I have a VBA code that will copy the latest row of sheet to another blank row on another sheet .

    [vba]

    Worksheets("Sheet1").Range("A" & Rows.Count).End(xlUp).EntireRow.Copy _
    Worksheets("Sheet5").Range("A" & Rows.Count).End(xlUp).Offset(1)
    Application.CutCopyMode = False
    [/vba]
    Now i need to copy the first row of Sheet1 to latest blank row of sheet5 .

    Thank you for your help .
    Last edited by Aussiebear; 04-06-2012 at 06:36 AM. Reason: Corrected the tags surrounding the submitted code (Again)

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]
    Worksheets("Sheet1").Rows(1).Copy _
    Worksheets("Sheet5").Range("A" & Rows.Count).End(xlUp).Offset(1)[/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Mentor
    Joined
    Feb 2012
    Posts
    406
    Location
    Thank you very much for your great work Xld.

  4. #4
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,054
    Location
    Quote Originally Posted by xld
    [vba]
    Worksheets("Sheet1").Rows(1).Copy _
    Worksheets("Sheet5").Range("A" & Rows.Count).End(xlUp).Offset(1)[/vba]
    How does Excel know what to do with the copied material?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by Aussiebear
    How does Excel know what to do with the copied material?
    You seem to have lost an underscore.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,054
    Location
    Perhaps I have ( since I copied your code) I not sure where it happened..... but how does that effect the outcome?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  7. #7
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    It changes one meaningful line to two syntactically incorrect lines.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  8. #8
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,054
    Location
    I understand the purpose of the underscore. I am more interested in the outcome of the two lines of code. Again I ask, How does Excel know what to do with the copied code?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  9. #9
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    It goes to the other range!
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  10. #10
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,054
    Location
    So effectively you need not tell Excel to paste the data. Are there other vba examples where excel knows without it having to be indicated?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  11. #11
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Copy has a Destination argument, so the paste is implicit.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  12. #12
    VBAX Regular
    Joined
    Aug 2011
    Posts
    87
    Location
    Quote Originally Posted by Aussiebear
    ... Are there other vba examples where excel knows without it having to be indicated?
    [vba][A1].Copy [B1][/vba]
    Regards
    Osvaldo

  13. #13
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,054
    Location
    Thank you
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  14. #14
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    That is not another one, it is just another way of the same sort of copy paste we were talking about. [...] is a shorthand (and horrible) way of calling Evaluate.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •