Solved

Ensuring a spreadsheet has only 420 rows in Excel

Posted on 2014-09-05
3
98 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 500 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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 …
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

739 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