Worksheet_change event using SELECT CASE

PATSYS

Well-known Member
Joined
Mar 12, 2006
Messages
1,750
Hi all,

I would like a worksheet_change event that will enter the value "Y" on a certain column depending on the target.column value (for the same row)

There must be many ways to do this but I would like to see how this is done using SELECT CASE

So if the target column is M, I would like the value "Y" to reflect on column X. If the target column is N, I would like the value "Y" to reflect on column V. If the target column is O, I would like the value "Y" to reflect on column Z.

Thanks
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Try something like:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Integer
If Target.Cells.Count > 1 Then Exit Sub 'Exits sub if more than a single cell changes at the same time
Application.EnableEvents = False    'Turns off the events
Select Case Target.Column
    Case Is = 13 'Column M
        i = 11
    Case Is = 14 'Column N
        i = 8
    Case Is = 15
        i = 11
    Case Else
        GoTo TheEnd 'Jumps to the turning the events back on part of the code
End Select
    Target.Offset(0, i).Value = "Y"
TheEnd:
Application.EnableEvents = True     'Turns the events back on
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,507
Messages
6,179,172
Members
452,893
Latest member
denay

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