Solved

Excel: Paste value to next blank row after X

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now