-
Solved: Trimming Things Down...
I have over 2,000 entries in one spreadsheet, with revenue figures in column
H, and the figures are sorted ascending
To provide the user with a quick overview on a printout, I wanted to
"compress" everything so it would fit onto one landscape-oriented page. By
compress I mean hide the middle values, not zoom out. By hiding the middle
values, only the biggest losers and the biggest gainers are shown.
How could I write a sub that kept hiding the middle rows until only 50 rows are visible?
-
Knowledge Base Approver
The King of Overkill!
VBAX Master
Hello,
Take a look at the following, should be what you need:[vba]Sub compariniaa()
With ActiveSheet.UsedRange
If .Rows.Count > 50 Then
.Range(.Rows(26), .Rows(.Rows.Count - 25)).EntireRow.Hidden = True
End If
End With
End Sub[/vba]Please let me know if its not what you're looking for!
Matt
-
This should show the top and bottom 25 values, whether the data is sorted or not.
Regards
MD
[VBA]Sub Ranks()
Dim MyRange As Range
Set MyRange = Intersect(Columns(8), ActiveSheet.UsedRange)
Application.ScreenUpdating = False
For Each cel In MyRange
If Application.WorksheetFunction.Rank(cel, MyRange) < MyRange.Cells.Count - 25 And _
Application.WorksheetFunction.Rank(cel, MyRange) > 25 Then
cel.RowHeight = 0
End If
Next
Application.ScreenUpdating = True
End Sub
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
-
Matt and MD, that's excellent! That's exactly what I needed, thank you very much for your help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules