ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   printing from Excel data (https://www.excelbanter.com/excel-discussion-misc-queries/4298-printing-excel-data.html)

Anthony

printing from Excel data
 
Hi,
Can anybody suggest some VB code that will allow me to select the LAST row
of data entered into a worksheet and print just this info, example


SMITH 123 JONES 456
JONES 897 SMITH 019
PAUL 876 PHIL 124

So I wish to select the last row of data ie PAUL 876 PHIL 124 and print
this in a separate form already produced on a separate sheet

Hope you can help

regards



SteveF

Anthony wrote:
Hi,
Can anybody suggest some VB code that will allow me to select the

LAST row
of data entered into a worksheet and print just this info, example


SMITH 123 JONES 456
JONES 897 SMITH 019
PAUL 876 PHIL 124

So I wish to select the last row of data ie PAUL 876 PHIL 124 and

print
this in a separate form already produced on a separate sheet

Hope you can help

regards



Assuming your data is in columns A-D of sheet1 and your "separate form"
starts
in B2 of Sheet2 then this code should work:

Sub printlast()
lastrow = Sheets("Sheet1").Range("a65536").End(xlUp).Row
Set fromrange = Sheets("sheet1").Range(Cells(lastrow, 1), _
Cells(lastrow, 4))
fromrange.Copy Sheets("sheet2").Range("b2")
End Sub



All times are GMT +1. The time now is 04:35 AM.

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