Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Format Number VBA

Sometimes it is useful to format numbers in a spreadsheet so that they
appear to be text.
To do this I just change the custom formatting as required - for
example "3M CO";"3M CO";"3M CO"
Now I have several hundred cells that need to be formatted in this
way.
I need a UDF that will take a value from one cell and format it
according to a string from another cell.

This is what I've got so far. The My_Value argument is number to be
formatted and the My_Formatting argument is the text that will be used
to format the cell.

Function Custom_Format(My_Value As Integer, My_Formatting As String)

Custom_Format = FormatNumber(My_Value, , My_Formatting, ,
My_Formatting)

End Function

Anyone got any ideas on where I'm going wrong??????????
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 449
Default Format Number VBA

Are you going wrong? I find no indication of that in your story. Please
explain.

Best wishes Harald

"5elpep" wrote in message
...
Sometimes it is useful to format numbers in a spreadsheet so that they
appear to be text.
To do this I just change the custom formatting as required - for
example "3M CO";"3M CO";"3M CO"
Now I have several hundred cells that need to be formatted in this
way.
I need a UDF that will take a value from one cell and format it
according to a string from another cell.

This is what I've got so far. The My_Value argument is number to be
formatted and the My_Formatting argument is the text that will be used
to format the cell.

Function Custom_Format(My_Value As Integer, My_Formatting As String)

Custom_Format = FormatNumber(My_Value, , My_Formatting, ,
My_Formatting)

End Function

Anyone got any ideas on where I'm going wrong??????????


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,365
Default Format Number VBA

This seems to work for me:

Function MakeCustomFormat(number As Integer, _
myFormat As String) As String

MakeCustomFormat = Format(number, myFormat)

End Function

with 3 in A1, and #M CO in B1 then in C1
=MakeCustomFormat(A1,B1)
displays 3M CO in C1

Does that help?

"5elpep" wrote:

Sometimes it is useful to format numbers in a spreadsheet so that they
appear to be text.
To do this I just change the custom formatting as required - for
example "3M CO";"3M CO";"3M CO"
Now I have several hundred cells that need to be formatted in this
way.
I need a UDF that will take a value from one cell and format it
according to a string from another cell.

This is what I've got so far. The My_Value argument is number to be
formatted and the My_Formatting argument is the text that will be used
to format the cell.

Function Custom_Format(My_Value As Integer, My_Formatting As String)

Custom_Format = FormatNumber(My_Value, , My_Formatting, ,
My_Formatting)

End Function

Anyone got any ideas on where I'm going wrong??????????

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
Replace million-billion number format to lakhs-crores format Sumit Excel Discussion (Misc queries) 1 December 9th 05 04:58 PM
Change number (in text format) to numeric format Pam Excel Discussion (Misc queries) 5 October 24th 05 07:45 PM
convert text-format number to number in excel 2000%3f Larry Excel Discussion (Misc queries) 1 July 29th 05 08:18 PM
Number format based on number format of another cell in another workbook Rob Excel Programming 9 January 9th 05 04:30 PM
excel format cells/Number/Category: Number problem Matts Excel Discussion (Misc queries) 5 December 9th 04 09:47 PM


All times are GMT +1. The time now is 11:12 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"