If, Then Statement based on Data Validation

cristopulo

New Member
Joined
Aug 12, 2015
Messages
14
Hello,

I am trying to use an If then Statement so that if certain text is selected in a data validation dropdown a certain value or formula is output.
The output I use is just as an example. I have just not been able to get it to read the If statement.

Sub Sheet2()
If Range("B11").Value = "ESB 63" Then
Range("C8").Value = "COOL"
End If


End Sub


Thanks,
Chris
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Hi Chris,

Change your sample code to this:
Code:
Sub Sheet2()
  
If Range("B11")= "ESB 63" Then
    Range("C8").Value = "COOL"
    End If

End Sub

That should do the trick
 
Upvote 0
Yep,

Still not working. On this sheet I am using 2 Active X option buttons. I have tried to include the IF statement as separate from the Option Button Code.

Could it be something within that is limiting it? I actually tried the same on another empty workbook and still couldn't get it to work.

Thanks,
Chris
 
Upvote 0
Hi Chris,

I've checked the code attached to a active X option button as well and it works for me but without further info i can't guess what you're aim is with the 2 option buttons and if (and if so) how they are driving the either the input or the output.
 
Upvote 0
Hello,

The 2 option buttons are grouped together and are on the same page of code for the data sheet. Each option button provides different input steps in order to select a product. For one of the inputs in each option button there is a Data Validation dropdown list (located in different cells for each option). When one option is selected in this dropdown list (ex. "ESB 63") I want to be able to change the output. Basically in the end it should include 2 different If/ Then Statements.

Is there a certain part of the code where I should include this (one within each option buttons code) or is that irrelevant?

Ive actually gotten it to work on another workbook, so I will see if I can manage.

Thank You,
Chris
 
Upvote 0
Hello again,

I am sorry, please disregard my previous post and I believe I know the problem.

Because the cell is not the specified value ("ESB 63") right when the option button is selected it will not read the cell changes. It actually starts off by saying "--Select--" in order to reset the cell in a way and inform the customer that there is a data validation choice in the cell.

Is there a way to have it read the cell at any point the option button is selected so that it changes even after a selection is made??
 
Upvote 0

Forum statistics

Threads
1,223,099
Messages
6,170,111
Members
452,302
Latest member
TaMere

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