Hover-over Function

R

Raul

Is it possible to have subroutine or function that will display the
"=weekday()" of a given date displayed in a message box if the contents of
that cell represents a date?

Ideally I'd like a "hover-over" function that would display the "=weekday()"
of the cell being hovered-over, but ......

Thanks in advance,
Raul
 
M

Mike Fogleman

This will use the cell comment to display the week day. The comment is
mouse-over by default.
Put this code in the worksheet code module:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim wkday As String
Dim comm As Comment
If IsDate(Target) Then
wkday = Weekday(Target)
If ActiveSheet.Comments.Count > 0 Then
For Each comm In ActiveSheet.Comments
If comm.Parent.Address = Target.Address Then
Target.Comment.Delete
End If
Next
End If
Target.AddComment "Weekday = " & wkday
End If
End Sub

Mike F
 
R

Raul

Mike,
Thanks for your response. I've inserted a module in the workbook I'm
working with and copied your code to this new modue. How do I pass the
"Target" range to this subroutine?

Thanks,
Raul
 
R

Raul

Mike,
Disregard my previous message. I inserted your code in the worksheet code
module (as you instructed) and it worked like a charm.

Thanks a bunch,
Raul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top