ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UDF to copy formatting as well as text? (https://www.excelbanter.com/excel-programming/421810-udf-copy-formatting-well-text.html)

CLR

UDF to copy formatting as well as text?
 
Hi All.......
Someone, (I don't remember who), sometime, (I don't remember when) was kind
enough to post this fine UDF.

Function copycomment(r As Range)
Application.Volatile
Dim whereami As Range
Set whereami = Application.Caller
If whereami.Comment Is Nothing Then
Else
whereami.Comment.Delete
End If
whereami.AddComment Text:=r.Value
copycomment = ""
End Function

It works great, but now I have a user who wishes to also retain the
FORMATTING from the copied cell as well as the text......is this possible?

TIA
Vaya con Dios,
Chuck, CABGx3



Jon Peltier

UDF to copy formatting as well as text?
 
UDFs are only supposed to change the value of a cell it is called from.
There are undocumented actions outside of this limited definition that can
be done with a UDF, but they are unreliable and can lead to instability. I
would consider mucking with comments to be among these undocumented actions.

Instead of a UDF, I would hook up similar code to a worksheet event.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services, Inc.
http://PeltierTech.com/WordPress/
_______


"CLR" wrote in message
...
Hi All.......
Someone, (I don't remember who), sometime, (I don't remember when) was
kind
enough to post this fine UDF.

Function copycomment(r As Range)
Application.Volatile
Dim whereami As Range
Set whereami = Application.Caller
If whereami.Comment Is Nothing Then
Else
whereami.Comment.Delete
End If
whereami.AddComment Text:=r.Value
copycomment = ""
End Function

It works great, but now I have a user who wishes to also retain the
FORMATTING from the copied cell as well as the text......is this possible?

TIA
Vaya con Dios,
Chuck, CABGx3






All times are GMT +1. The time now is 03:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com