Using case

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
 
M

Mike H

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
 
D

Don Guillett

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top