ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   UDF to return as text (https://www.excelbanter.com/excel-programming/437342-udf-return-text.html)

Fan924

UDF to return as text
 
This UDF returns a Hex number. I would like it to change the cell
format to text. Thanks,

Public Function DecToHex(DecNumber As Variant) As String
DecToHex = Right("0" & Hex(DecNumber), 2)
End Function

Ron Rosenfeld

UDF to return as text
 
On Fri, 11 Dec 2009 13:41:40 -0800 (PST), Fan924 wrote:

This UDF returns a Hex number. I would like it to change the cell
format to text. Thanks,

Public Function DecToHex(DecNumber As Variant) As String
DecToHex = Right("0" & Hex(DecNumber), 2)
End Function


A Function can only return a value. It cannot change the environment.
--ron

Fan924

UDF to return as text
 
A Function can only return a value. *It cannot change the environment.
--ron


Ok, thanks. That explains why nothing I tried worked. :)

ryguy7272

UDF to return as text
 
Maybe this:
=TEXT(A1, "0")

HTH,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Ron Rosenfeld" wrote:

On Fri, 11 Dec 2009 13:41:40 -0800 (PST), Fan924 wrote:

This UDF returns a Hex number. I would like it to change the cell
format to text. Thanks,

Public Function DecToHex(DecNumber As Variant) As String
DecToHex = Right("0" & Hex(DecNumber), 2)
End Function


A Function can only return a value. It cannot change the environment.
--ron
.


Ron Rosenfeld

UDF to return as text
 
On Fri, 11 Dec 2009 14:04:25 -0800 (PST), Fan924 wrote:

A Function can only return a value. *It cannot change the environment.
--ron


Ok, thanks. That explains why nothing I tried worked. :)


Perhaps with more information, someone might devise a solution to your problem.
--ron


All times are GMT +1. The time now is 04:45 AM.

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