Data Validation

irfman

New Member
Joined
Jan 1, 2019
Messages
9
I have entered a data validiation condition in cell A1 with options "Yes" and "No". In cell B2 i want the outcome as follows:


  • On selecting "Yes" option in A1, the value in cell B2 is automatically changed to 100%
  • On selecting "No" option in A1, no change takes place in cell B2 and the user is free to enter any value manually.

Is this possible? Appreciate any assistance in the matter.

Regards
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Copy and paste this macro into the worksheet code module. Do the following: right click the tab for your sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Cell B1 must be formatted as a percentage.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub
    If Target = "Yes" Then
        Range("B" & Target.Row) = 1
    End If
End Sub
 
Upvote 0
thanks a ton. really appreciate it. Is there any way if this can be done without using macros?
 
Upvote 0
thanks a ton. really appreciate it. Is there any way if this can be done without using macros?

Not if you allow the user to make manual entries into the destination cell.
 
Upvote 0
You are very welcome. :) @JLGWhiz has answered your question. If you don't allow manual entry, then this formula in B1 should work: =IF(A1="Yes",1,"")
 
Upvote 0
Copy and paste this macro into the worksheet code module. Do the following: right click the tab for your sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Cell B1 must be formatted as a percentage.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub
    If Target = "Yes" Then
        Range("B" & Target.Row) = 1
    End If
End Sub

what will be the change in VB code if cell A1 is located in work Sheet 1 and cell b2 is located in work sheet2.

thanks in anticipation.
 
Upvote 0
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub
    If Target = "Yes" Then
        Sheets("Sheet2").Range("B2") = 1
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,193
Members
452,616
Latest member
intern444

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