Minor change to VBA for Set Print Area

Livin404

Active Member
Joined
Jan 7, 2019
Messages
392
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Greetings, I've made a lot of progress on my set print area, using the VBA will help me keep the print area from being compromised. I created a macro that nearly gets me there, but I need it slightly changed. The final product I hope will not have the buttons. the range within the Columns goes from A to H. I provided an image which I hope helps. The near perfect VBA is below. There is data below, I just have it redacted. Thank you,

Capture pRINT.JPG


VBA Code:
Sub Set_Print_Area()

Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Application.ScreenUpdating = False

Dim startCell As Range, lastrow, lastCol As Long, ws As Worksheet
Set ws = Sheet1
Set startCell = Range("A1")
lastrow = ws.Cells(ws.Rows.Count, startCell.Column).End(xlUp).Row
lastCol = ws.Cells(startCell.Row, ws.Columns.Count).End(xlToLeft).Column

ws.Range(startCell, ws.Cells(lastrow, lastCol)).Select

Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
Application.ScreenUpdating = True

End Sub
 

Some videos you may like

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Livin404

Active Member
Joined
Jan 7, 2019
Messages
392
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Actually I think it will work as planned I just need to make sure there is no hidden values.
 

Livin404

Active Member
Joined
Jan 7, 2019
Messages
392
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
The formula worked as long as I have to cell color outside the ranges indicated in my VBA. I'm okay with that for now, I'll work on the capability of adding colors to the cells outside the range later.
Thank you
 
Solution

Watch MrExcel Video

Forum statistics

Threads
1,127,860
Messages
5,627,299
Members
416,237
Latest member
Tethys

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top