+ Reply to Thread
Results 1 to 4 of 4

Unique 'TextTips' Based on Hovered Over Cell Values (Hyperlinked)

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-15-2009
    Location
    Ontario, canada
    MS-Off Ver
    Office 365
    Posts
    371

    Unique 'TextTips' Based on Hovered Over Cell Values (Hyperlinked)

    With reference to this post ... https://www.excelforum.com/excel-pro...heet-cell.html, I am struggling to figure out a VBA solution to one of the components of my original post there. The solution provided fundamentally works (thank you Kokosek and Lewis), but I have not been able to figure out yet how to display the unique 'texttip' for the row that the user is hovering over. The code, as it is now, displays the same 'texttip' for each cell in that particular range (all the + in column I display "Heavy", ~ in column J display "Moderate" and "Light for column J's - ). I need to enhance those messages based on the row as: (apologize for being unable to display tabular, there are three columns of data illustrated here)

    Sym Row Message
    + 13 > 10 cm
    + 14 > 10 cm
    + 15 > 10 cm
    + 16 > 5 mm
    + 17 >5 mm
    + 18 >5 mm
    + 19 > 45 kph

    ~ 13 5-10 cm
    ~ 14 5-10 cm
    ~ 15 5-10 cm
    ~ 16 1-5 mm
    ~ 17 1-5 mm
    ~ 18 1-5 mm
    ~ 19 20-45 kph

    - 13 <5 cm
    - 14 <5 cm
    - 15 <5 cm
    - 16 <1 mm
    - 17 <1 mm
    - 18 <1 mm
    - 19 <20 kph

    Would anyone like to assist me in how to best approach this ... to display the appropriate 'texttip' based on which cell within the range the pointer is positioned? I suspect it might involve this portion of code, but I am unsure how to get the value for "srow" identified in my commented out lines of code. Perhaps it can't be done?

    Function GetScreenTipTextValue(v As Variant) As String
      'This returns 'Screen Tip Text' Values for certain inputs
      
      Dim sScreenTipText As String
      
      Select Case v
      Stop
        Case "+"
          sScreenTipText = "Plus"
          'if srow =>13 and row <= 16 then sScreenTipText = ">10 cm"
          'if srow =>17 and row <= 18 then sScreenTipText = ">5 mm"
          'if srow = 19 then sScreenTipText = ">45 kph"
        Case "~"
          sScreenTipText = "Moderate"
          'if srow =>13 and row <= 16 then sScreenTipText = "5-10 cm"
          'if srow =>17 and row <= 18 then sScreenTipText = "1-5 mm"
          'if srow = 19 then sScreenTipText = "20-45 kph"
        Case "-"
          sScreenTipText = "Minus"
         'if srow =>13 and row <= 16 then sScreenTipText = "<5 cm"
          'if srow =>17 and row <= 18 then sScreenTipText = "<1 mm"
          'if srow = 19 then sScreenTipText = "<20 kph"
      End Select
      
      'Set the return value
      GetScreenTipTextValue = sScreenTipText
    
    End Function

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Unique 'TextTips' Based on Hovered Over Cell Values (Hyperlinked)

    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
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    06-15-2009
    Location
    Ontario, canada
    MS-Off Ver
    Office 365
    Posts
    371

    Re: Unique 'TextTips' Based on Hovered Over Cell Values (Hyperlinked)

    Hi Lewis! Thank you so much. I was on the right track with my own guessing, but you cleaned things up for me. Working well!

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Unique 'TextTips' Based on Hovered Over Cell Values (Hyperlinked)

    I was happy to help. Your commented out lines in the code made things easy.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Graying out Specific Cell until Adjacent Cell is Hovered Over
    By richrew1492 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-17-2021, 03:31 AM
  2. [SOLVED] VBA to Print Hyperlinked PDF based on Cell Reference
    By hindotmo12 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-24-2020, 08:04 PM
  3. [SOLVED] Need Help Extracting Unique Values Based on Another Cell Value
    By rbhed77089 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-12-2018, 06:34 AM
  4. [SOLVED] Count unique values based on another cell value
    By terratushi in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-05-2018, 08:53 AM
  5. display value when hovered over a cell
    By deepakpalani in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-06-2014, 02:23 AM
  6. Count unique values based on value in another cell in same row
    By danbak in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-08-2013, 03:54 AM
  7. [SOLVED] Comments Appearing When Cell Is Selected (Not Hovered Over)
    By JB Christy in forum Excel General
    Replies: 2
    Last Post: 03-28-2006, 05:00 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1