ActiveSheet Hyperlinks Add don t show Text To Display

0 votes

I came across an unexpected behavior of the command ActiveSheet.Hyperlinks.Add in Excel VBA

If I use the following code

Sub Hyperlinks_Test()
Dim Link As String
Dim Text As String
Link = "www.google.com"
Text = "Link To Google"
ThisWorkbook.Worksheets("Sheet1").Activate

Cells(2, 2).Value = 3.14
ActiveSheet.Hyperlinks.Add Cells(2, 2), Address:="", SubAddress:=Link, TextToDisplay:=Text
Cells(3, 2).Value = #3/31/2023#
ActiveSheet.Hyperlinks.Add Cells(3, 2), Address:="", SubAddress:=Link, TextToDisplay:=Text
Cells(4, 2).Value = "String"
ActiveSheet.Hyperlinks.Add Cells(4, 2), Address:="", SubAddress:=Link, TextToDisplay:=Text
End Sub

I only get the right answer in cell (4,2), which has the text "Link To Google" and a hyperlink to www.google.com. Before I used the command "ActiveSheet.Hyperlinks.Add," if the cell contained a number or a date, the output was the number or the date instead of the title "Link To Google," but it correctly contained a hyperlink to www.google.com. (https://i.stack.imgur.com/RzBEe.jpg)

Is it a bug? ".Hyperlinks.Add "command or did I use the function incorrectly?

Mar 26, 2023 in Others by narikkadan
• 63,600 points
514 views

1 answer to this question.

0 votes
Here's how Excel functions. Not a bug, that is.
Texttodisplay does not function when a cell contains a number value that is "text" like or a number value.
You will notice that text to show is disabled if you manually attempt to insert a hyperlink in these cells in Excel.

Here, we first add the hyperlink before changing the cell's value.
answered Mar 26, 2023 by Kithuzzz
• 38,000 points

Related Questions In Others

0 votes
1 answer

Yoast Seo breadcrumbs: How to add custom text to category and tag name

use this code  add_filter('wpseo_breadcrumb_single_link', 'filter_breadcrumbs_for_h1', 10, 2); function filter_breadcrumbs_for_h1($link_output, ...READ MORE

answered Feb 12, 2022 in Others by narikkadan
• 63,600 points
718 views
0 votes
1 answer

Yoast Seo breadcrumbs: How to add custom text to category and tag name

add_filter('wpseo_breadcrumb_single_link', 'filter_breadcrumbs_for_h1', 10, 2); function filter_breadcrumbs_for_h1($link_output, $link) {     if ...READ MORE

answered Feb 25, 2022 in Others by narikkadan
• 63,600 points
1,457 views
0 votes
1 answer

How to add text on new page in word doc via excel vba

First start with: objDoc.Range.Insertafter vbCr & Chr(12) & ...READ MORE

answered Nov 25, 2022 in Others by narikkadan
• 63,600 points
1,895 views
–1 vote
0 answers
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
1,211 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
3,662 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9, 2022 in Others by gaurav
• 23,260 points
906 views
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,690 points
1,053 views
0 votes
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP