Minor change to VBA for Set Print Area

Livin404

Well-known Member
Joined
Jan 7, 2019
Messages
743
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
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Actually I think it will work as planned I just need to make sure there is no hidden values.
 
Upvote 0
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
 
Upvote 0
Solution

Forum statistics

Threads
1,215,529
Messages
6,125,343
Members
449,219
Latest member
Smiqer

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
Back
Top