Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 238
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 238
Default 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. :)
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default 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
.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Return Text based upon text matching klmiura Excel Worksheet Functions 6 January 30th 10 12:21 AM
Nested formula to search a text string and return specific text Barbie Excel Worksheet Functions 10 February 21st 09 07:40 AM
2 criteria lookup of text. Return text form column 3. SUMPRODUCT t zzxxcc Excel Worksheet Functions 2 August 26th 08 11:04 PM
When I hit return in a multiline text box, focus goes to next text wbntravis Excel Programming 1 March 7th 07 09:51 AM
lookup a text cell and return text Cristi R Excel Discussion (Misc queries) 4 August 2nd 06 02:41 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"