View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Otto Moehrbach
 
Posts: n/a
Default Set number format based on cell contents

All that is going to happen is that the format of C3 will change. If you
mean that the format is not changing then there is a problem. It worked for
me. So let's troubleshoot it.
Put the following line as the first line of the macro:
MsgBox "Working"
If you see the "Working" message box when you change the entry in B3, then
we know the macro is firing.
If you don't see that, then Excel is not recognizing the event of a change
in B3.
Close the file and close Excel.
Open Excel and open the file and see what happens when you change B3.
If this doesn't help, then I have to see the file myself.
If you wish, send me the file direct (do not post the file in the
newsgroup). If your file is large, make a copy of it and cut the file down
to small and make sure that the response of the macro (nothing) is still the
same. My email address is . Remove the "nop" from
this address. HTH Otto
"nospaminlich" wrote in message
...
Thanks Otto.

I've edited the code as shown below and put it in the Sheet1 Object page
but
when I change the cells in B3 nothing happens in C3.

Can't see what I've done wrong but I must have missed something.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(0, 0) = "B3" Then
If Target = "£" Then
Target.Offset(, 1).NumberFormat = "£#,##0.00"
Else
Target.Offset(, 1).NumberFormat = "General"
End If
Application.EnableEvents = False
Target.ClearContents
Application.EnableEvents = True
End If
End Sub