If then

trebor1956

Board Regular
Joined
Jul 2, 2015
Messages
100
Office Version
  1. 2013
Platform
  1. Windows
Hi,

I have col A with dropdown list (Pass or Fail) and col B with dropdown list (Y or N). If A2 has Fail and B2 has Y then I would like A2 entry changed to Pass. I seem to be going round in circles, hope you can help.

Thank you.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
What you are describing requires a macro. You can enter a value in column A (Pass or Fail), or you can have a formula =IF(B2="Y","Pass") but you can't have both at the same time.

Do you have this situation only in row 2, or is it repeated in many rows?
 
Upvote 0
Its repeated on many rows. The idea was that if a check fails - then "Fail" is selected from the dropdown in A2 then when it is fixed "Y" is selected from dropdown in B2 - when "Y" has been selected to say the issue is fixed then I was trying to find a way to automatically change A2 to "Pass".
 
Upvote 0
You can use this code in the module for the sheet containing the data you described. If you don't have experience with VBA I can give more details on how to do this.

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

   Dim Cell As Range

   For Each Cell In Target
      If Target.Column = 2 And Target = "Y" Then ' column B
         Cells(Target.Row, "A") = "Pass"
      End If
   Next Cell

End Sub
 
Upvote 0
Hi,
Thank you for the VBA code. I have put it into the s/sheet but nothing happens. Am I correct in assuming that Target.column = 2 (where 2 is column B)?
 
Upvote 0
I was a bit hasty. The Change event will not be triggered by a selection from a Data Validation dropdown. Let me take another look.
 
Upvote 0
The Change event will not be triggered by a selection from a Data Validation dropdown
It does for me.

@trebor1956
If you right click the tab of the sheet you want this to work on & select "View code", can you see the code in the window that opens?
 
Upvote 0
That's definitely odd, change events have always worked for me with data validation.
 
Upvote 0
Hi,
I put your code as follows;
Alt + F11
then copied your code into 'this workbook'
 
Upvote 0

Forum statistics

Threads
1,214,563
Messages
6,120,248
Members
448,952
Latest member
kjurney

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