Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Replace million-billion number format to lakhs-crores format | Excel Discussion (Misc queries) | |||
Change number (in text format) to numeric format | Excel Discussion (Misc queries) | |||
convert text-format number to number in excel 2000%3f | Excel Discussion (Misc queries) | |||
Number format based on number format of another cell in another workbook | Excel Programming | |||
excel format cells/Number/Category: Number problem | Excel Discussion (Misc queries) |