Solved

Excel VBA to hide Rows of Command Buttons that have no data

Posted on 2006-06-14
3
180 Views
Last Modified: 2010-04-30
I am using Excel VBA

I have a command button that you click to process, it calculates and puts data in the Range of A28:Q57 depending of the scenarios.   It may put data into A28:Q40, etc.

In column G28:G57 I have command buttons all the way down.  I want the rows that have no data in them, but have the command button, to hide the rows.

I start with this and not sure where to go from here
With Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)

Any help would be appreciated.
0
Comment
Question by:ca1358
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
[ fanpages ] earned 500 total points
ID: 16907903
Note quite sure what you need, but this code can be placed inside the _Click() event on any of the Command Buttons.  It will hide any row between 28 & 57 (inclusive) that does not contain any data...

Dim lngRow As Long

For lngRow = 28 to 57
    If Application.CountA(Rows(lngRow)) = 0 Then
       Rows(lngRow).Hidden = True
    End If
Next lngRow

'

BFN,

fp.
0
 

Author Comment

by:ca1358
ID: 16921229
Thank you!
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 16924433
You're very welcome.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

707 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

14 Experts available now in Live!

Get 1:1 Help Now