Worksheet_Change(ByVal Target As Range)

hartleyj

New Member
Joined
Jul 28, 2011
Messages
8
Hello,
I m trying to use the Change by Validation feature. When Cell B4 is changed to "YES" I want Cell B12 to change to yes. Both cells B4 and B12 are data list but I didn't think that would matter? Can you please take a look and let me know what I am doing wrong?

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$4" Then
If Range("B4").Value = "YES" Then
Range("b12").Value = "yes"

Else


End If

Application.EnableEvents = True

End If

End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
That should work if you have the uppercase and lowercase right.

This works fine for me:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    With Target
        If .Address = "$B$4" Then
            If .Value = "yes" Then Range("B12").Value = .Value
        End If
    End With
End Sub
 
Upvote 0
Hi, I think the code may be in infinite loop because you're constantly 'changing' the value.

So, just to add
Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    With Target
        If .Address = "$B$4" Then
            If .Value = "yes" Then Range("B12").Value = .Value
        End If
    End With
    Application.EnableEvents = True
End Sub
 
Upvote 0
Thank you all for your feed back. I used the code below and it's working great.

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
With Target
If .Address = "$B$4" Then
If .Value = "yes" Then Range("B12").Value = .Value
End If
End With
Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,568
Messages
6,179,595
Members
452,927
Latest member
whitfieldcraig

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