Macros

  • Thread starter Thread starter Dale
  • Start date Start date
D

Dale

How can I build a macro to take an amount, multiply it by -
1, then cut it and move it to the column on the left. I
want to be able to use it for many different amounts, so I
need to have a macro that doesn't save the amount in the
first cell that I build the macro with.

Thanks.
 
One way:

Public Sub Negate()
Dim cell As Range
For Each cell In Selection
With cell
If .Column <> 1 Then
.Offset(0, -1) = -.Value
.ClearContents
End If
End With
Next cell
End Sub

This will negate the value in each cell of the selection, place the
results in the cell to the left of those cells, and clear the
original selection.
 
Thanks very much for your help.

Dale.
-----Original Message-----
One way:

Public Sub Negate()
Dim cell As Range
For Each cell In Selection
With cell
If .Column <> 1 Then
.Offset(0, -1) = -.Value
.ClearContents
End If
End With
Next cell
End Sub

This will negate the value in each cell of the selection, place the
results in the cell to the left of those cells, and clear the
original selection.



.
 
Back
Top