VBA Help with Data Validation

Canadianexcel

New Member
Joined
Dec 23, 2010
Messages
39
Good Afternoon,

I am a bit stuck whatever I try is not working out as well as I hoped. Here is what I am trying to do.

- I have a Data Validation List in Column C a Yes No N/A and another list in Column D with a scale from 1-5.
- What I need is to clear any value in Column D if my first list is set changed to No or N/A.

I have attempted several example I found on google in the Private Sub Worksheet_Change(ByVal Target As Range). I was close with the following code my no cigar and I think I am looking at it to long, any help would be awesome

Dim ws As Worksheet
Dim x As Integer
Dim clearRng As Range


Application.ScreenUpdating = False


Set ws = ThisWorkbook.Sheets("Sheet1")


For x = 1 To ws.Range("J" & Rows.Count).End(xlUp).Row
If ws.Range("j" & x).Value = "No" Then
ws.Range("k" & x).Clear
ws.Range("k" & x).Select
ws.Range("k" & x).Value = 0
With Selection.Interior
.Pattern = xlUp
.PatternColor = 5287936
.ColorIndex = xlAutomatic
.TintAndShade = 0
.PatternTintAndShade = 0
End With
ElseIf ws.Range("j" & x).Value <> "No" Then
ws.Range("k" & x).Select
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End If



Next x


Application.ScreenUpdating = True


End Sub
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Is this what you want?
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
   If Target.CountLarge > 1 Then Exit Sub
   If Not Intersect(Target, Range("C:C")) Is Nothing Then
      If Target.Value <> "Yes" Then Target.Offset(, 1).Value = ""
   End If
End Sub
 
Upvote 0
You're welcome, let me know how it goes.
 
Upvote 0
Glad it helped & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,173
Members
453,021
Latest member
Justyna P

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