Forum Discussion

MargotKloeck's avatar
MargotKloeck
Copper Contributor
Jul 19, 2022

Excel other number

Hello, when I write in a cell a number (for example 40), I would like to, not see the number, but 24,84 for example.

 

And this for some other numbers too if this is possible. I don't know where I have to do this so I can get this result. All the numbers that have to change are in E so the number can also be in D, but can only change in E.

 

Thank you so much for answering.

Have a nice day!

3 Replies

  • Harun24HR's avatar
    Harun24HR
    Bronze Contributor

    Not clear what do you want to do? Can you show some sample data and desired output?

      • HansVogelaar's avatar
        HansVogelaar
        MVP

        MargotKloeck 

        You cannot do this with a formula, for a formula cannot refer to the cell itself. You need VBA code in the worksheet module:

        Private Sub Worksheet_Change(ByVal Target As Range)
            Dim rng As Range
            If Not Intersect(Range("E2:E1000"), Target) Is Nothing Then
                Application.ScreenUpdating = False
                Application.EnableEvents = False
                For Each rng In Intersect(Range("E2:E1000"), Target)
                    Select Case rng.Value
                        Case 40
                            rng.Value = 24.84 ' VBA uses decimal point, not comma
                        Case 401
                            rng.Value = 27.32
                        Case 25
                            rng.Value = 31.15
                        ' add other cases as needed
                    End Select
                Next rng
                Application.EnableEvents = True
                Application.ScreenUpdating = True
            End If
        End Sub

        See the attached version of your workbook. It is now a macro-enabled workbook, so you will have to allow macros. Right-click the sheet tab and select 'View Code' from the context menu to inspect and edit the code.

Resources