View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default format cells range

Yes......you would<g My slip.

Try this version which assumes J2 has a linking formula to a changing cell
on another sheet.

I also added the UCase to make the value in J2 case-insensitive.

i.e. usd or uSd or USd would be OK

Private Sub Worksheet_Calculate()
On Error GoTo endit
Application.EnableEvents = False
With Me.Range("F15:H20")
Select Case UCase(Me.Range("J2").Value)
Case "USD"
.NumberFormat = "$#,##0.00"
Case "GBP"
.NumberFormat = "£#,##0.00"
Case "KRN"
.NumberFormat = "Kr#,##0.00"
End Select
End With
endit:
Application.EnableEvents = True
End Sub

Gord

On Tue, 30 Sep 2008 13:50:01 -0700, diacci1st
wrote:

Hi
If I do that I get an error on the the below line for "object required"
If Intersect(Target, Me.Range("J2")) Is Nothing Then Exit Sub



"Gord Dibben" wrote:

Private Sub Worksheet_Calculate() 'only

drop this bit........ByVal Target As Range


Gord

On Tue, 30 Sep 2008 12:22:14 -0700, diacci1st
wrote:

Private Sub Worksheet_Calculate(ByVal Target As Range)
If Intersect(Target, Me.Range("J2")) Is Nothing Then Exit Sub
On Error GoTo endit
Application.EnableEvents = False
With Me.Range("F15:H20")
Select Case Target.Value
Case "USD"
.NumberFormat = "$#,##0.00"
Case "GBP"
.NumberFormat = "£#,##0.00"
Case "KRN"
.NumberFormat = "Kr#,##0.00"
End Select
End With
endit:
Application.EnableEvents = True
End Sub