View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] banderson@nwws.biz is offline
external usenet poster
 
Posts: 8
Default Compare columns and move data based on a value and change the sign to negative

To all the programming Guru's out there.
I'm trying to make some VB code that will look at a column and if the
value in that column is greater than 0,
move it to the corresponding column to the left and change the sign to
a negative.
Below is an example of data I am using.
Column A B C
CASH 125.00 0
CASH2 0 180.00
CASH3 0 12,000.00

So in the rows with cash2 and cash 3 I would like to move those values
to column B and make
them negative.
Below is the code I have that will move data based on an input box but
I have to put the value I want to change in there, and it will not
make the value negative. I would rather have this input box be set to
not equal to what I put in the box, but I'm not sure that an Input box
is designed to do that? Any help would be greatly appreciated.
Thank you

Sub Move_Stuff()
Dim topCel As Range
Dim bottomCel As Range

whatval = InputBox("Enter a Value")

Set topCel = Range("C1")
Set bottomCel = Cells((800), topCel.Column).End(xlUp)
If bottomCel.Row = topCel.Row Then
With Range(topCel, bottomCel)
Set c = .Find(whatval, LookIn:=xlValues, LookAt:=xlPart)
If Not c Is Nothing Then
Do
c.Cut Destination:=c.Offset(0, -1)
Set c = .FindNext
Loop While Not c Is Nothing
End If
End With
End If
End Sub