473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Hide every other row in MS Excel until the end of the document

Hi, I need to have a VB Macro to hide every other row in MS Excel until the end of the document.

For Example:

I need to starte at row 3, then hide 5, 7, 9, 11, all odds until the end.

Thanks.
Mar 25 '10 #1
4 5388
SammyB
807 Expert 512MB
You should be able to figure that one out, LOL. I got a little fancy: the macro is a toggle. If row 3 is visible, then hide the odds. If row 3 is already hidden, then show the rows:
Expand|Select|Wrap|Line Numbers
  1. Sub HideAndShow()
  2.     ' Determine last row
  3.     Dim n As Integer, i As Integer
  4.     n = Cells.SpecialCells(xlCellTypeLastCell).Row
  5.     ' Determine whether to hide or show
  6.     Dim isHidden As Boolean
  7.     isHidden = Rows(3).Hidden
  8.     ' Hide/Show the odd rows
  9.     For i = 3 To n Step 2
  10.         Rows(i).Hidden = Not isHidden
  11.     Next i
  12. End Sub
Mar 25 '10 #2
Yes, it worked like a charm! Thank you so much. You need to be working here!!
Mar 25 '10 #3
SammyB
807 Expert 512MB
Looks like I am ;o)
Did the IFERROR function work for you?
Mar 25 '10 #4
I thought about it and tried something different which ended up working a lot better.

Thanks again for all your help, you have saved me so much time and trouble, I really appreciate it.
Mar 25 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

19
by: benzwt | last post by:
I use the following function to hide a <div> named one. function hideObject() { if (ns4) { document.n1.visibility = "hide"; } else if (ie4) { document.all.style.visibility = "hidden"; }...
3
by: Vagabond Software | last post by:
Scenario: The end-user selects File-Save from my applications (WinForm) menu, specifies a filename, and waits waits for my app to write the contents of a dataset to an Excel workbook. The...
2
by: Flo | last post by:
Hello I want to be able to show/hide an application that is running. When i am getting the handles corresponding to an MS Office application (Excel for example), it appears that i get a handle...
0
by: Said | last post by:
hello, how can i open word, excel, pp document witout the standard commandbar so that the user couldn't use the options "save, save as, ctrl+F and ctrl+S,...". thanks for a quick answer.
1
by: tito | last post by:
Hi All, I am trying to write a code which will convert the Excel sheet document to Pie Diagarm using Perl Script.I have already searched in CPAN which gives the details of...
1
by: Raya | last post by:
Hi, I have a requirement as follows: I have a COBOL+DB2 program that inserts data into a DB2 table when an order is placed. Now, The same data should be inserted into the same table after every...
2
by: Ronald Raygun | last post by:
I have a document that is layed out in divs with ids and classes. There can be N divs of class "other" but only one div with id ="main". Only the div with id "main" should be visible. I want to...
15
by: jerrydigital | last post by:
Hello, I am trying to have a section of my form that allows users to "click here" to add additional account numbers. If they "click here", then an additional text box will appear. But, if they...
1
by: bloggerman | last post by:
I have a picture I'm posting that I don't want to be openly seen unless the viewer actively wishes to. It's nothing grotesque but I know some people can be queezy. Is there any way I can do that? I'm...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.