Change the sign of a cell

Solved
papyjlsn Posted messages 8 Status Member -  
 COUET -
Hello,

I would like to be able to change the + sign to - by clicking a button on the value it contains

For example, cell x = 930 click button and cell x = -930

I haven't found the VBA macro.

I am open to a solution

Thank you

6 answers

  1. Ericrxrx
     
    Hello,

    even simpler (this comes from Microsoft support):

    1. Enter the number -1 in an empty cell of the spreadsheet
    2. Select that cell
    3. In the Edit menu, choose the Copy command
    4. Select the range of cells whose sign you want to reverse
    5. In the Edit menu, choose the Paste Special command
    6. Select Paste Values and Multiplication Operation
    7. Click OK

    See you soon
    Eric
    10
    1. Ariane
       
      that's great
      thank you
      Ariane
      0
  2. kgigant Posted messages 223 Status Member 9
     
    ```vb Sub InverserSigne()
    Dim cel As Range
    For Each cel In Selection
    If cel.Value = "" Then
    Else
    If IsNumeric(cel) Then
    cel.Value = cel.Value * -1
    End If
    End If
    Next
    End Sub

    this code changes the sign of one or more selected cell(s) ```
    6
    1. COUET
       
      Great!
      Works perfectly...thank you.
      0
  3. papyjlsn Posted messages 8 Status Member
     
    Thank you for this quick response.

    This macro works perfectly.

    It is now integrated into my club management program, which now contains around 45 macros.
    0
  4. kgigant Posted messages 223 Status Member 9
     
    you should merge your macros
    0
  5. papyjlsn Posted messages 8 Status Member
     
    Merging macros, I don't know how to do it.

    However, I don't quite understand, as each one has its own function and they are created in the Visual Basic editor folder which is itself integrated into my Excel program.

    Thanks anyway for the info.
    0
  6. Papyjlsn
     
    I think the simplest solution is Kgigan's, which consists of a VBA macro that I run by pressing a button.
    It also works for one or more selected cells.
    Thank you for your response, though.

    Papyjlsn
    0