Solved

Ensuring a spreadsheet has only 420 rows in Excel

Posted on 2014-09-05
3
95 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
  • 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now