Forum Discussion
printing where the last data is entered In excel
1 Reply
- NikolinoDEPlatinum Contributor
To achieve your desired outcome of printing the data from column A to column D until the last row of data on one sheet, you can maybe adjust your VBA code as follows:
Vba code is untested, please backup your file in advance.
Sub prt() Dim LR As Long Dim ws As Worksheet Dim rngPrint As Range Set ws = ActiveSheet ' Find the last row with data in column D LR = ws.Cells(ws.Rows.Count, "D").End(xlUp).Row ' Define the range to print Set rngPrint = ws.Range("A1:D" & LR) ' Set print settings With ws.PageSetup .PrintArea = rngPrint.Address .Orientation = xlLandscape ' Set to landscape mode .FitToPagesWide = 1 ' Fit to one page wide .FitToPagesTall = False ' Do not fit to pages tall End With ' Print the defined range rngPrint.PrintOut End SubPlease Note: VBA macros themselves do not directly work in files stored on cloud storage platforms like Dropbox or OneDrive.
However, you can certainly store Excel files containing VBA macros on these platforms. When you open the Excel file from the cloud storage platform, you'll be able to run the macros as usual, provided that you enable macros when prompted and that your Excel settings allow for macros to run.
In other words, the macros are part of the Excel file, not the cloud storage platform itself. So as long as you're opening the Excel file in Excel (whether it's stored locally or in the cloud), the macros will work as intended. Just make sure to always enable macros from trusted sources to avoid potential security risks. The text was created with the help of AI.
My answers are voluntary and without guarantee!
Hope this will help you.
Was the answer useful? Mark as best response and like it!
This will help all forum participants.