PC Review


Reply
Thread Tools Rate Thread

How do I hide rows based on spedific conditions? (VBA novice)

 
 
rwinter
Guest
Posts: n/a
 
      10th Dec 2008
I would like to be able to automatically hide rows based on the value of a
particular cell in the same worksheet. I think that I should be able to do
this with a macro, but I have no experience writing my own macros, and need
thorough instructions for how to create/use a macros.

Here are some details about my excel 2003 spreadsheet: Close to the
beginning of the worksheet, there is a cell named PKG, this cell either gets
the value of "Pack of 1" or "Bulk". When PKG="Bulk", I would like rows
187-195 to be hidden, but I would like them to be displayed when PKG="Pack of
1". Could somebody please walk me through this?

Thanks!
 
Reply With Quote
 
 
 
 
Office_Novice
Guest
Posts: n/a
 
      10th Dec 2008
Be Glad Too...
It would look Somthing like this

Sub Marine()
If Range("PKG").Value = "Bulk" Then
Range("A187:A195").EntireRow.Hidden = True
Else
Range("A187-195").Hidden = True
End If
End Sub

"rwinter" wrote:

> I would like to be able to automatically hide rows based on the value of a
> particular cell in the same worksheet. I think that I should be able to do
> this with a macro, but I have no experience writing my own macros, and need
> thorough instructions for how to create/use a macros.
>
> Here are some details about my excel 2003 spreadsheet: Close to the
> beginning of the worksheet, there is a cell named PKG, this cell either gets
> the value of "Pack of 1" or "Bulk". When PKG="Bulk", I would like rows
> 187-195 to be hidden, but I would like them to be displayed when PKG="Pack of
> 1". Could somebody please walk me through this?
>
> Thanks!

 
Reply With Quote
 
Office_Novice
Guest
Posts: n/a
 
      10th Dec 2008
I really should read these first here is the right one

Sub Marine()
If Range("PKG").Value = "Bulk" Then
Range("A187:A195").EntireRow.Hidden = True
Else
Range("A187:A195").EntireRow.Hidden = False
End If
End Sub

Post back w/ any questions

"Office_Novice" wrote:

> Be Glad Too...
> It would look Somthing like this
>
> Sub Marine()
> If Range("PKG").Value = "Bulk" Then
> Range("A187:A195").EntireRow.Hidden = True
> Else
> Range("A187-195").Hidden = True
> End If
> End Sub
>
> "rwinter" wrote:
>
> > I would like to be able to automatically hide rows based on the value of a
> > particular cell in the same worksheet. I think that I should be able to do
> > this with a macro, but I have no experience writing my own macros, and need
> > thorough instructions for how to create/use a macros.
> >
> > Here are some details about my excel 2003 spreadsheet: Close to the
> > beginning of the worksheet, there is a cell named PKG, this cell either gets
> > the value of "Pack of 1" or "Bulk". When PKG="Bulk", I would like rows
> > 187-195 to be hidden, but I would like them to be displayed when PKG="Pack of
> > 1". Could somebody please walk me through this?
> >
> > Thanks!

 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      10th Dec 2008
How does PKG get changed?

Manually or by formula?

You could use sheet event code which runs automatically off the PKG value
when it is manually changed.

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Me.Range("PKG")) Is Nothing Then
If Target.Value = "bulk" Then
Me.Range("A187:A195").EntireRow.Hidden = True
Else
Me.Range("A187:A195").EntireRow.Hidden = False
End If
End If
End Sub


Gord Dibben MS Excel MVP



On Wed, 10 Dec 2008 11:57:01 -0800, rwinter
<(E-Mail Removed)> wrote:

>I would like to be able to automatically hide rows based on the value of a
>particular cell in the same worksheet. I think that I should be able to do
>this with a macro, but I have no experience writing my own macros, and need
>thorough instructions for how to create/use a macros.
>
>Here are some details about my excel 2003 spreadsheet: Close to the
>beginning of the worksheet, there is a cell named PKG, this cell either gets
>the value of "Pack of 1" or "Bulk". When PKG="Bulk", I would like rows
>187-195 to be hidden, but I would like them to be displayed when PKG="Pack of
>1". Could somebody please walk me through this?
>
>Thanks!


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop through a range of rows and hide based on conditions troy_lee@comcast.net Microsoft Excel Discussion 3 21st Oct 2008 08:10 PM
Hide/Show rows based on Conditions manfareed Microsoft Excel Programming 3 11th Sep 2008 04:04 PM
Deletion of rows based on Conditions =?Utf-8?B?SmVhbg==?= Microsoft Access Queries 3 17th May 2007 11:26 PM
How to Delete Rows Based on Conditions? hce Microsoft Excel Misc 4 11th May 2004 03:48 PM
How to Delete Rows based on conditions? hce Microsoft Excel Misc 4 10th May 2004 11:34 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:04 PM.