PC Review


Reply
Thread Tools Rate Thread

conditional row hide

 
 
=?Utf-8?B?aXZvcnlfa2l0dGVu?=
Guest
Posts: n/a
 
      18th Oct 2006
I have the following:


Private Sub Worksheet_Change(ByVal target As Range)
Application.ScreenUpdating = False
'Conditions & Ranges'
Dim rng As Range, rng2 As Range, rng3 As Range
Dim wf As WorksheetFunction
Dim cond1 As Boolean, cond2 As Boolean, cond3 As Boolean, cond4 As Boolean

Set wf = Application.WorksheetFunction
Set rng = Me.Range("E31") 'Option 2'
Set rng2 = Me.Range("B7") 'Packing Type'
Set rng3 = Me.Range("D2") 'Job Type
cond1 = (UCase(rng3.Value) = "Corporate")
cond2 = (UCase(rng3.Value) = "Private")
cond3 = (UCase(rng2.Value) = "PBR")
cond4 = (UCase(rng2.Value) = "PBO")

'Hides Packing Prices'
[37:37, 49:49].EntireRow.Hidden = wf.And(cond2, cond4)
[36:36, 48:48].EntireRow.Hidden = wf.Or(wf.And(cond1, cond3),
wf.And(cond2, cond4))

'Hides depending on Type'
[8:8, 41:43].EntireRow.Hidden = (rng3.Value = "Private")
[9:20, 34:34, 38:40, 46:46].EntireRow.Hidden = (rng3.Value = "Corporate")
'Hides Option 2'
If Not Intersect(rng, target) Is Nothing Then
[35:35, 47:47].EntireRow.Hidden = IsEmpty(rng.Value)
End If
Application.ScreenUpdating = True
End Sub

All the hiding parts work, except for the first block "Hide Packing Prices",
no rows are hiding!?

What I am trying to do is have row 36 and row 48 hide when D2 = "Corporate"
& B7 = "PBR" and also hide those 2 rows again when D2 = "Private" & B7 =
"PBO" and hide row 37 and row 49 as well with the second one.

What am I doing wrong?


 
Reply With Quote
 
 
 
 
Doug Glancy
Guest
Posts: n/a
 
      18th Oct 2006
ivory_kitten,

Ucase converts all letters in a string to upper case, so Ucase of no string
will ever be "Corporate." In the immediate window:

? UCase("Corporate")
CORPORATE

hth,

Doug


"ivory_kitten" <(E-Mail Removed)> wrote in message
news:05B437D7-CCBB-4F9F-B599-(E-Mail Removed)...
>I have the following:
>
>
> Private Sub Worksheet_Change(ByVal target As Range)
> Application.ScreenUpdating = False
> 'Conditions & Ranges'
> Dim rng As Range, rng2 As Range, rng3 As Range
> Dim wf As WorksheetFunction
> Dim cond1 As Boolean, cond2 As Boolean, cond3 As Boolean, cond4 As
> Boolean
>
> Set wf = Application.WorksheetFunction
> Set rng = Me.Range("E31") 'Option 2'
> Set rng2 = Me.Range("B7") 'Packing Type'
> Set rng3 = Me.Range("D2") 'Job Type
> cond1 = (UCase(rng3.Value) = "Corporate")
> cond2 = (UCase(rng3.Value) = "Private")
> cond3 = (UCase(rng2.Value) = "PBR")
> cond4 = (UCase(rng2.Value) = "PBO")
>
> 'Hides Packing Prices'
> [37:37, 49:49].EntireRow.Hidden = wf.And(cond2, cond4)
> [36:36, 48:48].EntireRow.Hidden = wf.Or(wf.And(cond1, cond3),
> wf.And(cond2, cond4))
>
> 'Hides depending on Type'
> [8:8, 41:43].EntireRow.Hidden = (rng3.Value = "Private")
> [9:20, 34:34, 38:40, 46:46].EntireRow.Hidden = (rng3.Value =
> "Corporate")
> 'Hides Option 2'
> If Not Intersect(rng, target) Is Nothing Then
> [35:35, 47:47].EntireRow.Hidden = IsEmpty(rng.Value)
> End If
> Application.ScreenUpdating = True
> End Sub
>
> All the hiding parts work, except for the first block "Hide Packing
> Prices",
> no rows are hiding!?
>
> What I am trying to do is have row 36 and row 48 hide when D2 =
> "Corporate"
> & B7 = "PBR" and also hide those 2 rows again when D2 = "Private" & B7 =
> "PBO" and hide row 37 and row 49 as well with the second one.
>
> What am I doing wrong?
>
>



 
Reply With Quote
 
=?Utf-8?B?aXZvcnlfa2l0dGVu?=
Guest
Posts: n/a
 
      18th Oct 2006
OMG i feel so stupid! LOL thanks alot!

"Doug Glancy" wrote:

> ivory_kitten,
>
> Ucase converts all letters in a string to upper case, so Ucase of no string
> will ever be "Corporate." In the immediate window:
>
> ? UCase("Corporate")
> CORPORATE
>
> hth,
>
> Doug
>
>
> "ivory_kitten" <(E-Mail Removed)> wrote in message
> news:05B437D7-CCBB-4F9F-B599-(E-Mail Removed)...
> >I have the following:
> >
> >
> > Private Sub Worksheet_Change(ByVal target As Range)
> > Application.ScreenUpdating = False
> > 'Conditions & Ranges'
> > Dim rng As Range, rng2 As Range, rng3 As Range
> > Dim wf As WorksheetFunction
> > Dim cond1 As Boolean, cond2 As Boolean, cond3 As Boolean, cond4 As
> > Boolean
> >
> > Set wf = Application.WorksheetFunction
> > Set rng = Me.Range("E31") 'Option 2'
> > Set rng2 = Me.Range("B7") 'Packing Type'
> > Set rng3 = Me.Range("D2") 'Job Type
> > cond1 = (UCase(rng3.Value) = "Corporate")
> > cond2 = (UCase(rng3.Value) = "Private")
> > cond3 = (UCase(rng2.Value) = "PBR")
> > cond4 = (UCase(rng2.Value) = "PBO")
> >
> > 'Hides Packing Prices'
> > [37:37, 49:49].EntireRow.Hidden = wf.And(cond2, cond4)
> > [36:36, 48:48].EntireRow.Hidden = wf.Or(wf.And(cond1, cond3),
> > wf.And(cond2, cond4))
> >
> > 'Hides depending on Type'
> > [8:8, 41:43].EntireRow.Hidden = (rng3.Value = "Private")
> > [9:20, 34:34, 38:40, 46:46].EntireRow.Hidden = (rng3.Value =
> > "Corporate")
> > 'Hides Option 2'
> > If Not Intersect(rng, target) Is Nothing Then
> > [35:35, 47:47].EntireRow.Hidden = IsEmpty(rng.Value)
> > End If
> > Application.ScreenUpdating = True
> > End Sub
> >
> > All the hiding parts work, except for the first block "Hide Packing
> > Prices",
> > no rows are hiding!?
> >
> > What I am trying to do is have row 36 and row 48 hide when D2 =
> > "Corporate"
> > & B7 = "PBR" and also hide those 2 rows again when D2 = "Private" & B7 =
> > "PBO" and hide row 37 and row 49 as well with the second one.
> >
> > What am I doing wrong?
> >
> >

>
>
>

 
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
Conditional Hide Admin @ Aust-Mech Microsoft Excel Worksheet Functions 5 16th Mar 2009 12:30 AM
conditional hide jim3975 Microsoft Excel Discussion 4 7th May 2007 09:42 AM
Conditional Hide rows with zero =?Utf-8?B?Vmxvb2t1cCBoZWxw?= Microsoft Excel Programming 2 4th Feb 2005 09:41 PM
Conditional Hide... Please Help! =?Utf-8?B?Sm9uYXRoYW4gRy4=?= Microsoft Excel Misc 1 18th Oct 2004 07:19 PM
Conditional format to hide #N/A Ann Scharpf Microsoft Excel Worksheet Functions 3 21st Oct 2003 02:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:59 PM.