Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Ankeny, Iowa, USA
    Posts
    344
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Macro-Copy & Paste at end of selection (Excel 2002)

    Hi,
    I'm trying to copy about 10 rows of new data from one area of a spreadsheet and then paste it at the BOTTOM of a database in another area of the same worksheet. My attempt at the macro didn't work of course... the part I have a problem with is the code that would determine the END or BOTTOM of the database so that I can paste the new data underneath it. I tried to use the End(xlDown)).Select code, then scrolling down one, and this didn't work.
    Thanks!!
    Lana
    Sub PasteAtBottomOfData()

    Range("AA2:AP10").Select
    Selection.copy
    Range("A2").Select
    Range(Selection, Selection.End(xlDown)).Select
    ActiveWindow.SmallScroll Down:=1
    Selection.PasteSpecial Paste:=xlPasteValues
    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro-Copy & Paste at end of selection (Excel 2002)

    Scrolling doesn't affect the active cell, it only moves the screen display. Try

    Sub PasteAtBottomOfData()
    Range("AA2:AP10").Copy
    Range("A65536").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues
    End Sub

    Note that the code doesn't select any cells explicitly. This is not necessary in general.
    A65536 is the bottommost cell in column A.
    Range("A65536").End(xlUp) moves up to the last filled cell in column A.
    Offset(1, 0) moves one cell down, i.e. to the first empty cell.

  3. #3
    3 Star Lounger
    Join Date
    Jul 2002
    Location
    Ankeny, Iowa, USA
    Posts
    344
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Re: Macro-Copy & Paste at end of selection (Excel 2002)

    It works perfect! I really love this stuff! Thanks so much for helping me learn Hans... you can't possibly know how much I appreciate it! I've been a macro writing fool this week and have you to thank for teaching me what I know so far. I also appreciate the explanations you give me when you give me some code... this helps tremendously!
    Have a good evening!
    Lana

Posting Permissions

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