Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Excel: Paste value to next blank row after X

Posted on 2015-02-03
5
162 Views
Last Modified: 2016-02-11
Hello,

Seeking your help on the following -

I would like to copy a cell and paste it to another sheet - to the first blank row in column A (after row A8).

I currently have this code - can you please assist:

Sub mac_pastevalue
'
' mac_pastevalue


' Here I copy a cell and then choose another active sheet

    Sheets("PO Template").Select
    Range("R12").Select
    Selection.Copy
    Sheets("PO Request Summary").Select

'Here I want to paste the above into the first blank row in column A, after A8
  

End Sub

Open in new window

0
Comment
Question by:dabug80
  • 3
  • 2
5 Comments
 
LVL 11

Expert Comment

by:Wilder1626
ID: 40587643
You can try this:

  Sheets("PO Template").Select
        Range("R12").Select
        Range(Selection, Selection.End(xlDown)).Copy Destination:=Sheets("PO Request Summary").Range("A8" & Rows.Count).End(xlUp).Offset(1)

Open in new window


or


  Sheets("PO Template").Range("R12").Select
        Range(Selection, Selection.End(xlDown)).Copy Destination:=Sheets("PO Request Summary").Range("A8" & Rows.Count).End(xlUp).Offset(1)

Open in new window

0
 
LVL 1

Author Comment

by:dabug80
ID: 40587664
Thanks. I tried both. And I get the same error.

For the two line code I get:

Runtime error: 1004:

Application-defined or object-defined error

With the debug on line 2.
0
 
LVL 11

Accepted Solution

by:
Wilder1626 earned 400 total points
ID: 40587678
sorry. Try link this

Sheets("PO Template").Range("R12").Copy Destination:=Sheets("PO Request Summary").Range("A8").End(xlUp).Offset(1, 0)

Open in new window

0
 
LVL 1

Assisted Solution

by:dabug80
dabug80 earned 0 total points
ID: 40587701
Thanks,

I altered the code to read 'Down' instead of 'Up' and it worked as needed. Here's the final code:

Sub mac_testpaste()
'
' mac_testpaste Macro

Sheets("PO Template").Select
        Range("R12").Select
        Sheets("PO Template").Range("R12").Copy Destination:=Sheets("PO Request Summary").Range("A8").End(xlDown).Offset(1, 0)
End Sub

Open in new window

0
 
LVL 1

Author Closing Comment

by:dabug80
ID: 40596625
Small adjustment to the code to make the VBA add values from the bottom, not the top.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question