More than one worksheet change

leighmills33

Board Regular
Joined
Mar 28, 2008
Messages
56
Hi,

I am having an issue with a worksheet change event, I have three drop down menus at F30,H30 and J30. When I change the drop down for F30 I want the values F21,F25 and F28 to change, when I change the drop down for H30 I want H25 to change and same for J30 with values J21,J23,J26 and J29 changing.

The problem I am getting is only my F value cells are changing when I change, F30, H30 and J30.

I need it so that when I can also change the value of "0mm".

I have attached my code, I also have an example if any one would like me to send it to them.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target <> Range("F30") Then Exit Sub

If Range("F30").Value = "AS ABOVE" Then
    Range("F21").Value = "0mm"
    Range("F25").Value = "0mm"
    Range("F28").Value = "0mm"

End If
If Range("F30").Value = "THREE EQUAL" Then
    Range("F21").Value = ""
    Range("F25").Value = ""
    Range("F28").Value = ""
End If


If Target <> Range("H30") Then Exit Sub
If Range("H30").Value = "AS ABOVE" Then
    Range("H25").Value = "0mm"
    
End If
If Range("H30").Value = "LETTER BOX" Then
    Range("H25").Value = ""
End If



If Target <> Range("J30") Then Exit Sub
If Range("J30").Value = "AS ABOVE" Then
    Range("J21").Value = "0mm"
    Range("J23").Value = "0mm"
    Range("J26").Value = "0mm"
    Range("J29").Value = "0mm"
    
End If
If Range("J30").Value = "FOUR EQUAL" Then
    Range("J21").Value = ""
    Range("J23").Value = ""
    Range("J26").Value = ""
    Range("J29").Value = ""
End If


End Sub

Thanks
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Try this (untested)
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target = Range("F30") Then
    If Range("F30").Value = "AS ABOVE" Then
        Range("F21").Value = "0mm"
        Range("F25").Value = "0mm"
        Range("F28").Value = "0mm"
    End If
    If Range("F30").Value = "THREE EQUAL" Then
        Range("F21").Value = ""
        Range("F25").Value = ""
        Range("F28").Value = ""
    End If
End If

If Target = Range("H30") Then
    If Range("H30").Value = "AS ABOVE" Then
        Range("H25").Value = "0mm"
    End If
    If Range("H30").Value = "LETTER BOX" Then
        Range("H25").Value = ""
    End If
End If

If Target = Range("J30") Then
    If Range("J30").Value = "AS ABOVE" Then
        Range("J21").Value = "0mm"
        Range("J23").Value = "0mm"
        Range("J26").Value = "0mm"
        Range("J29").Value = "0mm"
    End If
    If Range("J30").Value = "FOUR EQUAL" Then
        Range("J21").Value = ""
        Range("J23").Value = ""
        Range("J26").Value = ""
        Range("J29").Value = ""
    End If
End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,534
Messages
6,179,391
Members
452,909
Latest member
VickiS

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