Macro case

  • Thread starter Thread starter bren
  • Start date Start date
B

bren

Hi,

I want a macro to confirm a cell value with a msgbox. For example, If
A1 has value 4, the msgbox says OK, if cell value is 8, the msgbox
says NEAR and if the cell value isn´t one of these two values then
msgbox has to show BAD. I´ve tried with CASE but it hasn´t worked. I
think I´ve done something wrong.

Thank you so much
 
Dim myCell as range

set mycell = worksheets("Somesheetnamehere").range("A1")

select case mycell.value
case is = 4:msgbox "Ok"
case is = 8:msgbox "Near"
case else
msgbox "Bad"
End Select

========
But I don't know when you would run this--after the cell changed? After the
cell recalculated (if it contained a formula?

Personally, for these kinds of things (if they're not part of a larger project),
I find that using an adjacent cell formatted in big, bold, red letters is
better.

=if(a1=4,"ok",if(a1=8,"Near","Bad"))
 
Back
Top