Solved

Excel: Paste value to next blank row after X

Posted on 2015-02-03
5
161 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

777 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