Hover over cell - display value from other cell

virtuosok

Board Regular
Joined
Sep 2, 2020
Messages
209
Office Version
  1. 365
Platform
  1. Windows
Hi,
I understand it's only possible to do so via VBA?
I have a range B3:X17 on Tab1, and I wonder if by hovering over, let's say, cell C10 in Tab1, I can see an entry from cell C10 in Tab2 from within the same workbook - so that it pops up as a ScreenTip. Same for all other cells. Thanks in advance for any ideas!
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Would it not be a way forward to write the tips in as comments?

But i guess you could make the code to insert text from tab 2 as a comment in tab 1?

dave
 
Upvote 0
This code will add the comments from b3 to x17. However, this may not suit your needs.

I dont think there is a hover over feature we can use in a sheet.

VBA Code:
Sub add_comments()
For a = 3 To 17
    For b = 2 To 24
        With Sheets("Tab1").Cells(a, b)
            .AddComment
            .Comment.Text Text:=Sheets("Tab2").Cells(a, b).Text
        End With
    Next b
Next a
End Sub
 
Upvote 0
Solution
also FYI

if you are open to the user right clicking the cell, this will give a message box

VBA Code:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
    If Intersect(Target, Range("B3:X17")) Is Nothing Then Exit Sub
    MsgBox Sheets("Tab2").Range(ActiveCell.Address)
    Cancel = True
End Sub

OR

this will add a comment, then remove it after the next right click event

VBA Code:
Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
Range("B3:X17").ClearComments
If Intersect(Target, Range("B3:X17")) Is Nothing Then Exit Sub
    With ActiveCell
        .AddComment
        .Comment.Text Text:=Sheets("Tab2").Range(ActiveCell.Address).Text
    End With
Cancel = True
End Sub

just giving options

dave
 
Upvote 0
GREAT! I like it the first solution!
Is there a way to reduce the default size of the comment field though, I have 2 to 6 characters to display only; a smaller comment box would look nicer :)
 
Upvote 0
hi

add this at the bottom of the code


VBA Code:
For Each mycom In Application.ActiveSheet.Comments
    mycom.Shape.TextFrame.AutoSize = True
Next
 
Upvote 0
like this for ease

VBA Code:
Sub add_comments()

For a = 3 To 17
    For b = 2 To 24
        With Sheets("Tab1").Cells(a, b)
            .AddComment
            .Comment.Text Text:=Sheets("Tab2").Cells(a, b).Text
        End With
    Next b
Next a

For Each mycom In Application.ActiveSheet.Comments
    mycom.Shape.TextFrame.AutoSize = True
Next

End Sub
 
Upvote 0
Thanks! It doesn't auto-resize though, not sure why... saved of course as xlsm, reopened the file a few times...
 

Attachments

  • crop.png
    crop.png
    18.4 KB · Views: 16
Upvote 0
my mistake

sorry

try below, i used activesheet by mistake

VBA Code:
Sub add_comments()

For a = 3 To 17
    For b = 2 To 24
        With Sheets("Tab1").Cells(a, b)
            .AddComment
            .Comment.Text Text:=Sheets("Tab2").Cells(a, b).Text
        End With
    Next b
Next a


For Each mycom In Application.Sheets("Tab1").Comments
    mycom.Shape.TextFrame.AutoSize = True
Next

End Sub
 
Upvote 0
Still auto-resize is not working for me... but I can live with that :)
Thanks!
 
Upvote 0

Forum statistics

Threads
1,215,543
Messages
6,125,429
Members
449,223
Latest member
Narrian

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top