VBA - Set Triggercell Range Based on Another Cell

Shelby21

Board Regular
Joined
Nov 21, 2017
Messages
51
Office Version
  1. 365
Platform
  1. Windows
Hi guys,

I need some help with setting a trigger cell range based on input from another cell.

In cell C24, their is a drop down selection that allows you to select CR or PASS

In cell C25, their is another drop down that allows you to select Lw-Lw or Lw-Up

Based on input from cell C24 and C25, rows 35 and 39 are both displayed. This is not what I want to do.

If I select CR in cell C24 and Lw-Lw in cell C25, I only want row 39 to be displayed.

I need a way for my code to identify whether I select CR or PASS in cell C24 and then display the appropiate row when I select Lw-Lw instead of displaying both rows.

cr.PNG


VBA Code:
Set Triggercell = Range("C25")
   
    If Not Application.Intersect(Triggercell, Target) Is Nothing Then
            If Triggercell.value = "Lw-Lw" Then
                Rows("35").Hidden = False
                Rows("32:34").Hidden = True
            ElseIf Triggercell.value = "" Then
                Rows("32:35").Hidden = True
            End If
    End If

Set Triggercell = Range("C25")
   
    If Not Application.Intersect(Triggercell, Target) Is Nothing Then
            If Triggercell.value = "Lw-Lw" Then
                Rows("39").Hidden = False
                Rows("36:38").Hidden = True
            ElseIf Triggercell.value = "" Then
                Rows("36:39").Hidden = True
            End If
    End If
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
What should happen if Pass or Lw-Up are selected?
 
Upvote 0
What should happen if Pass or Lw-Up are selected?
Hi Fluff,

I can explain this a bit further to help you understand.

PASS and CR refer to 2 different robots. Both PASS and CR have same hand designations for Lw-Up and Lw-Lw.

If you select PASS, you have the option to select either Lw-Up or Lw-Lw.
There are actually 4 selections to choose from, but for the purpose of keeping this request simplified, I am limiting it to the two mentioned above.

If you select CR, you also have the option to select either Lw-Up or Lw-Lw.

Depending on which robot you select and which hand you select, I would like the appropriate IO status row to be displayed.
 
Upvote 0
Ok, for that one example, how about
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.CountLarge > 1 Then Exit Sub
   If Not Intersect(Target, Range("C24:C25")) Is Nothing Then
      If Range("C24").Value = "CR" And Range("C25").Value = "Lw-Lw" Then
         Rows(39).Hidden = False
      Else
         Rows(39).Hidden = True
      End If
   End If
End Sub
 
Upvote 0
Solution
Ok, for that one example, how about
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.CountLarge > 1 Then Exit Sub
   If Not Intersect(Target, Range("C24:C25")) Is Nothing Then
      If Range("C24").Value = "CR" And Range("C25").Value = "Lw-Lw" Then
         Rows(39).Hidden = False
      Else
         Rows(39).Hidden = True
      End If
   End If
End Sub
That worked perfectly. Tested it with both PASS Lw-Lw and Cr Lw-Lw and the correct IO status is now being displayed.

Thank you!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,488
Members
448,967
Latest member
visheshkotha

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