Adds amount to active cell, or subtract
Applies to selected cell in current active sheet.
Only if 1 cell is selected, if that cell has number, and only if that cell has a constant (Not formula).
Sub Cell_Add_or_Subtract(Amount, Optional Plus1_or_Subtract2 = 1, Optional CellAddress = "ActiveCell")
' Adds amount to active cell, or subtract
' Only if 1 cell is selected, and only if that cell has a constant (Not formula)
If CellAddress = "ActiveCell" Then CellAddress = Selection.Address
If Range(CellAddress).Rows.Count > 1 Then Exit Sub
If Range(CellAddress).Columns.Count > 1 Then Exit Sub
If Left(Range(CellAddress).Formula, 1) = "=" Then Exit Sub
If Not IsNumeric(Range(CellAddress).Value) Then Exit Sub
If Not IsNumeric(Amount) Then Exit Sub
Amount2Add = Amount
If Plus1_or_Subtract2 = 2 Then Amount2Add = 0 - Amount
Range(CellAddress).Value = Range(CellAddress).Value + Amount2Add
End Sub
' Adds amount to active cell, or subtract
' Only if 1 cell is selected, and only if that cell has a constant (Not formula)
If CellAddress = "ActiveCell" Then CellAddress = Selection.Address
If Range(CellAddress).Rows.Count > 1 Then Exit Sub
If Range(CellAddress).Columns.Count > 1 Then Exit Sub
If Left(Range(CellAddress).Formula, 1) = "=" Then Exit Sub
If Not IsNumeric(Range(CellAddress).Value) Then Exit Sub
If Not IsNumeric(Amount) Then Exit Sub
Amount2Add = Amount
If Plus1_or_Subtract2 = 2 Then Amount2Add = 0 - Amount
Range(CellAddress).Value = Range(CellAddress).Value + Amount2Add
End Sub
Amount, Optional Plus1_or_Subtract2 = 1, Optional CellAddress = "ActiveCell"
Sub My2022_Plus100()
Cell_Add_or_Subtract 100
End Sub
Sub My2022_Minus100()
Cell_Add_or_Subtract 100, 2
End Sub
Cell_Add_or_Subtract 100
End Sub
Sub My2022_Minus100()
Cell_Add_or_Subtract 100, 2
End Sub
Views 91
Downloads 44
CodeID
DB ID