T
TSW632
Cross posted from Excel.Programming
Anyone know why some code would work fine when not plugged into my
company’s LAN, but not when I am plugged into the LAN? I mean, other
than Macro Security, is there something else I should be checking?
The
Macro Security shows medium in either condition, but the code will
not
work when I am on the LAN… And while I'm here, anyone know what to
change in NumberFormat so a
currency symbol will be displayed with negative figures as well as
positive?
Thanks, Troy
Here is the code:
Private Sub Worksheet_Calculate()
Const CURRENCYTYPES As String = ":GBP£:JPY¥:EUR€:USD$:CAD$:MEX$:BRL
$:"
Static pv As Variant
Dim cv As Variant
cv = Me.Range("V35").Value2
'unless the current value (cv) is a 4-char string different than
the
cached
'previous value (pv), there's nothing to do, so exit quickly
If cv = pv Or VarType(cv) <> vbString Or Len(CStr(cv)) <> 4 Then
Exit Sub
Else
cv = ":" & cv & ":"
End If
If InStr(1, CURRENCYTYPES, cv, vbTextCompare) > 0 Then
Me.Range("F49:AF49").NumberFormat = Mid$(cv, 5, 1) & "_([$ -2] *
#,##0_);_([$ -2] * (#,##0);_([$ -2] * ""-""_);_(@_)"
pv = Mid$(cv, 5, 1)
End If
End Sub
Anyone know why some code would work fine when not plugged into my
company’s LAN, but not when I am plugged into the LAN? I mean, other
than Macro Security, is there something else I should be checking?
The
Macro Security shows medium in either condition, but the code will
not
work when I am on the LAN… And while I'm here, anyone know what to
change in NumberFormat so a
currency symbol will be displayed with negative figures as well as
positive?
Thanks, Troy
Here is the code:
Private Sub Worksheet_Calculate()
Const CURRENCYTYPES As String = ":GBP£:JPY¥:EUR€:USD$:CAD$:MEX$:BRL
$:"
Static pv As Variant
Dim cv As Variant
cv = Me.Range("V35").Value2
'unless the current value (cv) is a 4-char string different than
the
cached
'previous value (pv), there's nothing to do, so exit quickly
If cv = pv Or VarType(cv) <> vbString Or Len(CStr(cv)) <> 4 Then
Exit Sub
Else
cv = ":" & cv & ":"
End If
If InStr(1, CURRENCYTYPES, cv, vbTextCompare) > 0 Then
Me.Range("F49:AF49").NumberFormat = Mid$(cv, 5, 1) & "_([$ -2] *
#,##0_);_([$ -2] * (#,##0);_([$ -2] * ""-""_);_(@_)"
pv = Mid$(cv, 5, 1)
End If
End Sub