Macros

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.
 
J

J.E. McGimpsey

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.
 
D

Dale

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.



.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top