tooltip/comment macro

Rose Lloyd 1 Reputation point
2022-02-20T20:29:01.8+00:00

I am working on a macro that will read the cell texts in the first row (header row) and return a tooltip (or comment if anyone has the code) with an explanation of the text in the cell. I pull a report several times and have 50+ column headers to define. The columns are not ever in the same place as before. With the macro, my analysis assists the receivers of the report as well as myself.

This is what I have so far:

‘Select the range of headers, either automatically or manually before triggering the macro headerRange=Range([first cell],[last cell)
‘or
headerRange=Selection
‘iterate through each cell of the range
For Each headerCell in headerRange
‘read the value
headerValue=headerCell.Value
‘choose the tooltip
Select Case headerValue
Case “AA”
Tooltip=”Tooltip for AA”
Case “AB”
Tooltip=”tooltip for AB”
‘…more cases
Case Else ‘default
Tooltip=””
End Select
‘write the tooltip
With headerCell.Validation
.Delete
.Add Type:=xlValidateCustom
.InputMessage=tooltip
End With

Next headerCell

0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.