Using case

  • Thread starter Thread starter Risky Dave
  • Start date Start date
R

Risky Dave

Hi,

From the worksheet code window, I am trying to identify when certain cells
are modified and execute various functions according to different criteria.

I am trying to do this by using a case statement based on the value of
Target.Column, but nothing seems to be happening (no errors coming up, but
not the result I was expecting either).

I have:

Private Sub Worksheet_Change(ByVal Target As Range)

Select Case Target
Case Target.Column = 3
MsgBox ("column" & Target.Column)
Case Target.Column = 4
MsgBox("column" & Target.Column)
End Select

Obviously, in the final code, MsgBox willbe replaced by stuff that actually
does useful things, but for now can someone tell me how to get this working,
and if it won't how can I achieve this sort of result (it needs to be based
on the column modified)

TIA

Dave
 
You were very close

Private Sub Worksheet_Change(ByVal Target As Range)

Select Case Target.Column
Case Is = 3
MsgBox ("column" & Target.Column)
Case Is = 4
MsgBox ("column" & Target.Column)
Case Else
'Do something else
End Select

End Sub


Mike
 
Private Sub Worksheet_Change(ByVal Target As Range)
MsgBox "Column " & Target.Column
End Sub
 
Back
Top