Hi,
Try the attached copy of your modified file. The '-' sign column worked intermittently for me, so I changed it to 'x' and it worked every time for me. You may want to try to change it back to '-' sign, and see how it works for you.
In the future, please upload your sample file to the thread - you will get better and quicker responses, as responders want to do as little work as possible testing and looking for files.
Changed code follows:
Function GetScreenTipTextValue(v As Variant, iRow As Long) As String
'This returns 'Screen Tip Text' Values for certain inputs
Dim sScreenTipText As String
xSelect xCase v
xCase "+"
xSelect xCase iRow
xCase 13 To 15
sScreenTipText = ">10 cm"
xCase 16, 17, 18
sScreenTipText = ">5 mm"
xCase 19
sScreenTipText = ">45 kph"
End xSelect
xCase "~"
xSelect xCase iRow
xCase 13 To 15
sScreenTipText = "5-10 cm"
xCase 16, 17, 18
sScreenTipText = ">1-5 mm"
xCase 19
sScreenTipText = "20-45 kph"
End xSelect
'NOTE: Had intermittent results with '-', replaced with 'x' and seemed to work all the time
xCase "x"
xSelect xCase iRow
xCase 13 To 15
sScreenTipText = "<5 cm"
xCase 16, 17, 18
sScreenTipText = "<1 mm"
xCase 19
sScreenTipText = "<20 kph"
End xSelect
End xSelect 'Set the return value
GetScreenTipTextValue = sScreenTipText
End Function
Sub AddScreenTipTextToCell(r As Range)
'This adds 'Screen Tip Text' to a cell by creating a dummy hyperlink
'Nothing is done if the input range is more than one cell
'
'The existing 'Screen Tip Text' is DELETED before adding the new 'Screen Tip Text'
'even if there is NO NEW 'Screen Tip Text'
Dim sScreenTipText As String
Dim vValue As Variant
'Stop
'Font attributes
Dim sFontName As String
Dim sFontStyle As String
Dim xFontSize As Double
Dim bStrikethrough As Boolean
Dim bSuperscript As Boolean
Dim bSubscript As Boolean
Dim bOutlineFont As Boolean
Dim bShadow As Boolean
Dim iUnderline As Long
Dim iColorIndex As Long
Dim iRow As Long
'Exit if the input range is more than one cell
If r.Count > 1 Then
Exit Sub
End If
'Get the value in the Cell
'Get the Row Number
vValue = r.Value
iRow = r.Row
''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''
'Get the the 'Screen Tip Text' Value
''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''
sScreenTipText = GetScreenTipTextValue(vValue, iRow)
'Get the values of various Font Attributes of the cell
'This is needed because adding a Hyperlink changes Font Attributes
With r.Font
sFontName = .Name
sFontStyle = .FontStyle
xFontSize = .Size
bStrikethrough = .Strikethrough
bSuperscript = .Superscript
bSubscript = .Subscript
bOutlineFont = .OutlineFont
bShadow = .Shadow
iUnderline = .Underline
iColorIndex = .ColorIndex
End With
'Remove any Hyperlink from the Cell
r.Hyperlinks.Delete
'Create the Dummy HyperLink that contains 'Screen Tip Text'
'only if the 'Screen Tip Text' value is NOT BLANK
If Len(sScreenTipText) > 0 Then
ActiveSheet.Hyperlinks.Add _
Anchor:=r, _
Address:="", _
SubAddress:="", _
ScreenTip:=sScreenTipText
'Set the values of various Font Attributes of the cell to the original values
With r.Font
.Name = sFontName
.FontStyle = sFontStyle
.Size = xFontSize
.Strikethrough = bStrikethrough
.Superscript = bSuperscript
.Subscript = bSubscript
.OutlineFont = bOutlineFont
.Shadow = bShadow
.Underline = iUnderline
.ColorIndex = iColorIndex
End With
End If
End Sub
NOTE: Had to replace 'Case' with 'xCase' and 'Select' with 'xSelect' to get past Excelforum firewall
Lewis
Bookmarks