#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 161
Default Using case

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Using case

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

"Risky Dave" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 161
Default Using case

Mike,

My thanks.

One day I'll get the hang of this :-)


Dave
"Mike H" wrote:

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

"Risky Dave" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
countif function: how to distinguish case/make case sensitive mvwoolner Excel Worksheet Functions 3 March 18th 09 02:18 PM
change data of entire column from small case to upper case Ann Excel Worksheet Functions 1 August 16th 08 01:06 PM
Changing multiple cell text from lower case to upper case Patti Excel Discussion (Misc queries) 2 January 4th 08 08:35 PM
Change the text from lower case to upper case in an Excel work boo dave01968 Excel Discussion (Misc queries) 2 December 9th 05 09:09 AM
How do I change existing text from lower case to upper case CT Cameron Excel Discussion (Misc queries) 2 November 30th 04 01:07 AM


All times are GMT +1. The time now is 10:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"