|
Current Special! Complete Excel
Excel
Training Course
for Excel 97 - Excel 2003, only $145.00.
$59.95 Instant
Buy/Download,
30 Day Money Back Guarantee & Free
Excel Help for LIFE!
Got any Excel Questions? Free Excel Help
Limit or Restrict Scroll Area on an Excel Worksheet. See Also: Limit/Restrict Scroll Area on an Excel Worksheet Non VBA Solution.
With the aid of Excel VBA and the Worksheet Selection Event we can restrict the scrollable area on any Excel Worksheet. The code below must be placed in the Private Module of the Worksheet Object. To get their quickly, right click on the Sheet name tab and choose View Code. In here paste the code below. It will restrict the scroll area to only those cells which house data. Note it leaves one extra row and column. This is so more data can be added and the scrollable area is automatically expanded.
Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim LastColumn As Integer Dim LastRow As Long If WorksheetFunction.CountA(Cells) > 0 Then 'Search for any entry, by searching backwards by Rows. LastRow = Cells.Find(What:="*", After:=[A1], _ SearchOrder:=xlByRows, _ SearchDirection:=xlPrevious).Row If LastRow <> 65536 Then LastRow = LastRow + 1 'Search for any entry, by searching backwards by Columns. LastColumn = Cells.Find(What:="*", After:=[A1], _ SearchOrder:=xlByColumns, _ SearchDirection:=xlPrevious).Column If LastColumn <> 256 Then LastColumn = LastColumn + 1 Me.ScrollArea = Range(Cells(1, 1), Cells(LastRow, LastColumn)).Address Else Me.ScrollArea = "" End If End Sub
If you wish to use such code on all Worksheets in the Workbook. Place the code below into the Private Module of the Workbook Object (ThisWorkbook). To get here quickly right click on the Excel icon, top left next to File and choose View Code. In here paste the code below;
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range) Dim LastColumn As Integer Dim LastRow As Long Dim LastCell As Range If WorksheetFunction.CountA(Sh.Cells) > 0 Then 'Search for any entry, by searching backwards by Rows. LastRow = Sh.Cells.Find(What:="*", After:=Sh.Cells(1, 1), _ SearchOrder:=xlByRows, _ SearchDirection:=xlPrevious).Row If LastRow <> 65536 Then LastRow = LastRow + 1 'Search for any entry, by searching backwards by Columns. LastColumn = Sh.Cells.Find(What:="*", After:=Sh.Cells(1, 1), _ SearchOrder:=xlByColumns, _ SearchDirection:=xlPrevious).Column If LastColumn <> 256 Then LastColumn = LastColumn + 1 Sh.ScrollArea = Range(Cells(1, 1), Cells(LastRow, LastColumn)).Address Else Sh.ScrollArea = "" End If End Sub
Excel Dashboard Reports & Excel Dashboard Charts 50% Off Become an ExcelUser Affiliate & Earn Money
Special! Free Choice of Complete Excel Training Course OR Excel Add-ins Collection on all purchases totaling over $64.00. ALL purchases totaling over $150.00 gets you BOTH! Purchases MUST be made via this site. Send payment proof to [email protected] 31 days after purchase date.
Instant Download and Money Back Guarantee on Most Software
Excel Trader Package Technical Analysis in Excel With $139.00 of FREE software!
Microsoft � and Microsoft Excel � are registered trademarks of Microsoft Corporation. OzGrid is in no way associated with Microsoft
Some of our more popular products are below...
Convert Excel Spreadsheets To Webpages | Trading In Excel | Construction Estimators | Finance Templates & Add-ins Bundle | Code-VBA | Smart-VBA | Print-VBA | Excel Data Manipulation & Analysis | Convert MS Office Applications To...... | Analyzer Excel | Downloader Excel
| MSSQL Migration
Toolkit |
Monte Carlo Add-in |
Excel
Costing Templates