ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   macro to select data/paste/print (https://www.excelbanter.com/excel-worksheet-functions/10573-macro-select-data-paste-print.html)

Anthony

macro to select data/paste/print
 
Ok,

Sorry to those who have posted a reply to me before, but now I and my basic
VB programming methods are very confused,

I have a workbook containing several sheets.
Sheet 1 contains rows of data, which are frequently added to. (the first row
of data starts on A8:L8, the next added data would be A9:L9 and so on€¦.)

What I wish to do is have a macro button which will SELECT THE LAST ROW OF
DATA ENTERED ON SHEET 1 and paste this info onto another sheet in the same
format

This selected pasted data will then be printed off.

After new rows of data have been added to sheet 1, I would want the macro to
select the very last row of data entered again and paste/print etc etc

Can anybody provide the basic VB code for this, as I cant get it to work
(as easy as it may seem)

Many many thanks

Anthony


Nick Hodge

Anthony

I suspect you do not just want the data pasted to row A in the second
worksheet, but that is what the code below does. If that has to be pasted
to the bottom of an ever expanding range, post back. Here is some code to
get you going

Sub PasteLastLineToSheet2()
Dim wks1 As Worksheet, wks2 As Worksheet
Dim lLastRow As Long
Set wks1 = Worksheets("Sheet1")
Set wks2 = Worksheets("Sheet2")
lLastRow = wks1.Range("A65536").End(xlUp).Row
wks1.Range("A" & lLastRow).EntireRow.Copy _
Destination:=wks2.Range("A1")
wks1.PrintOut
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
HIS


"Anthony" wrote in message
...
Ok,

Sorry to those who have posted a reply to me before, but now I and my
basic
VB programming methods are very confused,

I have a workbook containing several sheets.
Sheet 1 contains rows of data, which are frequently added to. (the first
row
of data starts on A8:L8, the next added data would be A9:L9 and so on..)

What I wish to do is have a macro button which will SELECT THE LAST ROW OF
DATA ENTERED ON SHEET 1 and paste this info onto another sheet in the same
format

This selected pasted data will then be printed off.

After new rows of data have been added to sheet 1, I would want the macro
to
select the very last row of data entered again and paste/print etc etc

Can anybody provide the basic VB code for this, as I can't get it to work
(as easy as it may seem)

Many many thanks

Anthony





All times are GMT +1. The time now is 04:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com