Additional VBA Help

jUStPunkin

Board Regular
Joined
Mar 23, 2009
Messages
67
All,

I have recieved some help on this prior, but I've been asked to refine the results a little more.
These are the potential combinations.
Sheet Hidden
G_TwoTieredG_CapturedAboveG_FeedTypeSpoutSpouts2Redistribution Calculation
NNLIQUIDVisibleHiddenHidden
NNMIXEDVisibleHiddenHidden
NNVAPORHiddenHiddenHidden
NYLIQUIDHiddenVisibleVisible
NYMIXEDHiddenVisibleVisible
NYVAPORHiddenHiddenHidden
YYLIQUIDHiddenHiddenHidden
YYMIXEDHiddenHiddenHidden
YYVAPORHiddenHiddenHidden
YNLIQUIDHiddenHiddenHidden
YNVAPORHiddenHiddenHidden
YNMIXEDHiddenHiddenHidden


And this is the code I have currently; it does not account for the G_Feedtype variable.

VBA Code:
    Dim IsNo As Boolean
        If UCase(Range("G_TwoTiered").Value) = "Y" Then
        Sheets("Spouts").Visible = False
        Sheets("Spouts2").Visible = False
        Sheets("Redistribution Calculations").Visible = False
    Else
        IsNo = UCase(Range("G_CapturedAbove").Value) = "N"
        Sheets("Spouts").Visible = IsNo
        Sheets("Spouts2").Visible = Not IsNo
        Sheets("Redistribution Calculations").Visible = Not IsNo
    End If

Is there a way I can update this code, or do I need to try something else? Basically, in addition to what is dictated in the above code, anytime FeedType is set to Mixed or Liquid, I need to hide Spouts, Spouts2 and Redistribution Calculations sheets.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
past code into a module, then run using sheet to enter into cells, or a form
USAGE:

'ENTER THE PARAMS
getHideVals "Y", "Y", "LIQUID", bSpoutHide, bSpouts2Hide, bRedistHide

'HIDE COLS
Columns("D:D").EntireColumn.Hidden = bSpoutHide
Columns("E:E").EntireColumn.Hidden = bSpouts2Hide
Columns("F:F").EntireColumn.Hidden = bRedistHide



Code:
Private bSpoutHide As Boolean, bSpouts2Hide As Boolean, bRedistHide As Boolean
Const kHIDE = "HIDDEN"

Public Function getHideVals(ByVal pvG2Tier, ByVal gvGCapAbove, ByVal pvGFeed, pbSpout As Boolean, pbSpouts2 As Boolean, pbRedistrib As Boolean)
Dim iRows As Long

iRows = 13
Range("A2").Select

'turn ON filter
Selection.AutoFilter
With ActiveSheet.Range("$A$1:$F$" & iRows)
    .AutoFilter Field:=1, Criteria1:=pvG2Tier
    .AutoFilter Field:=2, Criteria1:=gvGCapAbove
    .AutoFilter Field:=3, Criteria1:=pvGFeed
End With

  'which row is winner?
While ActiveCell.Height = 0
   ActiveCell.Offset(1, 0).Select
   If ActiveCell.Value = "" Then
     MsgBox "Parameters not found"
     End
   End If
Wend

pbSpout = UCase(ActiveCell.Offset(0, 3).Value) = kHIDE
pbSpouts2 = UCase(ActiveCell.Offset(0, 4).Value) = kHIDE
pbRedistrib = UCase(ActiveCell.Offset(0, 5).Value) = kHIDE

'turn off filter
Selection.AutoFilter

End Function
 
Upvote 0

Forum statistics

Threads
1,215,150
Messages
6,123,312
Members
449,094
Latest member
Chestertim

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top