Macro based on multiple conditions

Dhoffl

New Member
Joined
Jun 10, 2020
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
I have a very limited understanding of macro and VBA

I am trying to make a hidden row appear only if the following conditions are met:

1. A specific option is selected from one drop down menu
2.Any of 4 options (mme, lc, isb or cre) are selected from another drop down list which contains multiple other options
2. At least two cells in a range of four cells are populated with "yes"

if not all criteria are met the row should remain hidden.

Any pointers on this would be great as I have been effectively teaching myself from YouTube and excel forums and have hit a wall on this one.
 

Some videos you may like

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
Assuming your first dropdown list is in cell A1 and you second dropdown list is in cell B1 and you range for the 'yes' critereis is C1:C4
VBA Code:
If Range("A1").Value = "Specific Option" Then
    If Range("B2").Value = "mme" Or Range("B2").Value = "lc" Or Range("B2").Value = "isb" Or Range("B2").Value = "cre" Then
       If Application.CountI(Range("C1:C4"), "yes") = 2 Then
           Rows(5).Hidden = True
       End If
    End If
End If
 

Dhoffl

New Member
Joined
Jun 10, 2020
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
Thank you for sharing that. I get an error saying application doesnt support that object or method. It highlighting the row Application.countI
 

Dhoffl

New Member
Joined
Jun 10, 2020
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
Thank you for sharing that. I get an error saying application doesnt support that object or method. It highlighting the row Application.countI
Oops Sorry, ignore me I realise I needed it to be count if. thank you so much for your help!
 

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
Oops Sorry, ignore me I realise I needed it to be count if. thank you so much for your help!
Yes, it was a typo. Glad you could fix it.
Regards, JLG
 

Watch MrExcel Video

Forum statistics

Threads
1,127,931
Messages
5,627,690
Members
416,266
Latest member
stevenvanroeden

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
Top