I am trying to change the text and its appearance in a VBA function (changeCell
).
option explicit
function changeCell(txt as string, sz as long) as range
cells(4,4).value = txt
cells(4,4).font.size = sz
cells(4,4).font.bold = true
cells(4,4).font.color = rgb(255, 100, 0)
set changeCell = cells(5,5)
end function
When I call changeCell("foo", 20)
, the text is changed as I expected it.
However, If this function is called from a =hyperlink()
worksheet function, the font.size
and font.bold
property is not changed (although font.color
and .value
is).
This is the function I used to insert the hyperlink on the sheet:
sub insertHyperlink()
cells(2,2).formula = "=hyperlink(""#changeCell(""""hyperlink was clicked"""", 99)"", ""click me to change cell"")"
end sub
I am trying to use the =hyperlink()
function because I need to be able to pass parameter values to the function that is invoked. These values are determined when the =hyperlink()
function is inserted (which doesn't happen manually, but with a function like insertHyperlink
, albeit more elaborate)
I am wondering why that is and how I can change the font size in a function that is called by =hyperlink()
.