?
Solved

Ensuring a spreadsheet has only 420 rows in Excel

Posted on 2014-09-05
3
Medium Priority
?
101 Views
Last Modified: 2014-09-10
Experts,

I have mulitple worksheets within a workbook.  I want each worksheet to have only 420 rows and no more.  Is there a way in VB, I can delete all rows after row 420.

I have the spreadsheet set to display only up to 420, but however I am performing a delete operation which deletes rows from the original 420 when there is no data on the respective row.
0
Comment
Question by:morinia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40306700
I'm not a huge fan of this method I'm about to suggest, but you can hide all rows from 421 to the last row.  That will limit the display to row 420.

If you have a macro-based option that deletes the rows as you described, you could augment it to unhide an equal amount of rows below to keep the display at 420 rows.  

Regards,
-Glenn
0
 
LVL 1

Accepted Solution

by:
Subramani N earned 2000 total points
ID: 40306709
Include this in your vba and try if it works.
Application.ActiveSheet.UsedRange
totalcount = Worksheets("SheetName").UsedRange.Rows.Count
If totalcount > 420 Then
    Rows("421:totalcount").Delete
End

Open in new window

0
 
LVL 27

Expert Comment

by:Glenn Ray
ID: 40306734
Just a follow-up:  If you do hide rows 421-onward, they will stay hidden even if you delete rows in the visible area.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question