Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
number format
I'd like a person to be able to alter the number of
decimal places in one cell by typing a number in another. eg if you type 3 in A1 then A2 is formatted to 3 decimal places. I've recored a macro to see the code but the number format is "0.000" Is there any way of doing this? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
number format
Lisa,
This works for A3. Change the range if you want to apply to more Dim sFormat As String On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Me.Range("A3")) Is Nothing Then With Target If IsNumeric(.Value) Then sFormat = "0." & Left("0000000000", .Value) .Offset(-1, 0).NumberFormat = sFormat End If End With End If ws_exit: Application.EnableEvents = True End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "LiSa" wrote in message ... I'd like a person to be able to alter the number of decimal places in one cell by typing a number in another. eg if you type 3 in A1 then A2 is formatted to 3 decimal places. I've recored a macro to see the code but the number format is "0.000" Is there any way of doing this? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
number format
Use ROUND, referring to A1. This formula rounds the value in cell D1 to the
number of decimal places in A1: =ROUND(D1,A1) Stan Scott NYC "LiSa" wrote in message ... I'd like a person to be able to alter the number of decimal places in one cell by typing a number in another. eg if you type 3 in A1 then A2 is formatted to 3 decimal places. I've recored a macro to see the code but the number format is "0.000" Is there any way of doing this? |
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) | |||
How do i change numbers in text format to number format? | New Users to Excel | |||
excel format cells/Number/Category: Number problem | Excel Discussion (Misc queries) |