ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   enter opposite number one row below (https://www.excelbanter.com/excel-programming/374130-enter-opposite-number-one-row-below.html)

andresg1975

enter opposite number one row below
 
Can someone help me on this.
lets say i have

column O

row 1 150
row 2
row 3 92
row 4
row 5 70
row 6

how can i create a macro that goes to column O, enters the value of the cell
above in this case 150, one row below having opposite sign -150, insert a row
below, and continue the same procedure. In this case, making 92 as -92 one
row below and insert a new row, and so on. Thanks a lot.


Don Guillett

enter opposite number one row below
 
change ,1 to ,"o"

Sub putnumbers()
For i = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
If Cells(i, 1) 0 Then Cells(i + 1, 1) = -Cells(i, 1)
Next i
End Sub

--
Don Guillett
SalesAid Software

"andresg1975" wrote in message
...
Can someone help me on this.
lets say i have

column O

row 1 150
row 2
row 3 92
row 4
row 5 70
row 6

how can i create a macro that goes to column O, enters the value of the
cell
above in this case 150, one row below having opposite sign -150, insert a
row
below, and continue the same procedure. In this case, making 92 as -92 one
row below and insert a new row, and so on. Thanks a lot.




andresg1975

enter opposite number one row below
 
I didn't explain myself clear
the macro is only taking positive signs and converting them to minus signs.
It should be a macro converting positive to minus, and minus to positives.
thanks again.

at the end it shoul be like this

150
-150

-400
400

-250
250

150 change to -150, insert a row
-400 change to 400, insert a row

"Don Guillett" wrote:

change ,1 to ,"o"

Sub putnumbers()
For i = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
If Cells(i, 1) 0 Then Cells(i + 1, 1) = -Cells(i, 1)
Next i
End Sub

--
Don Guillett
SalesAid Software

"andresg1975" wrote in message
...
Can someone help me on this.
lets say i have

column O

row 1 150
row 2
row 3 92
row 4
row 5 70
row 6

how can i create a macro that goes to column O, enters the value of the
cell
above in this case 150, one row below having opposite sign -150, insert a
row
below, and continue the same procedure. In this case, making 92 as -92 one
row below and insert a new row, and so on. Thanks a lot.





Don Guillett

enter opposite number one row below
 
try this. Notice the step -2

Sub putnumbers()
For i = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -2
Cells(i + 1, 1) = -Cells(i, 1)
Next
End Sub

--
Don Guillett
SalesAid Software

"andresg1975" wrote in message
...
I didn't explain myself clear
the macro is only taking positive signs and converting them to minus
signs.
It should be a macro converting positive to minus, and minus to positives.
thanks again.

at the end it shoul be like this

150
-150

-400
400

-250
250

150 change to -150, insert a row
-400 change to 400, insert a row

"Don Guillett" wrote:

change ,1 to ,"o"

Sub putnumbers()
For i = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
If Cells(i, 1) 0 Then Cells(i + 1, 1) = -Cells(i, 1)
Next i
End Sub

--
Don Guillett
SalesAid Software

"andresg1975" wrote in message
...
Can someone help me on this.
lets say i have

column O

row 1 150
row 2
row 3 92
row 4
row 5 70
row 6

how can i create a macro that goes to column O, enters the value of the
cell
above in this case 150, one row below having opposite sign -150, insert
a
row
below, and continue the same procedure. In this case, making 92 as -92
one
row below and insert a new row, and so on. Thanks a lot.







andresg1975

enter opposite number one row below
 
can u tell me which 1 should i change to replace for my column I
thanks

"Don Guillett" wrote:

try this. Notice the step -2

Sub putnumbers()
For i = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -2
Cells(i + 1, 1) = -Cells(i, 1)
Next
End Sub

--
Don Guillett
SalesAid Software

"andresg1975" wrote in message
...
I didn't explain myself clear
the macro is only taking positive signs and converting them to minus
signs.
It should be a macro converting positive to minus, and minus to positives.
thanks again.

at the end it shoul be like this

150
-150

-400
400

-250
250

150 change to -150, insert a row
-400 change to 400, insert a row

"Don Guillett" wrote:

change ,1 to ,"o"

Sub putnumbers()
For i = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
If Cells(i, 1) 0 Then Cells(i + 1, 1) = -Cells(i, 1)
Next i
End Sub

--
Don Guillett
SalesAid Software

"andresg1975" wrote in message
...
Can someone help me on this.
lets say i have

column O

row 1 150
row 2
row 3 92
row 4
row 5 70
row 6

how can i create a macro that goes to column O, enters the value of the
cell
above in this case 150, one row below having opposite sign -150, insert
a
row
below, and continue the same procedure. In this case, making 92 as -92
one
row below and insert a new row, and so on. Thanks a lot.








Don Guillett

enter opposite number one row below
 
I thought I had done that ,1 ,"o"

Sub putnumbers()
For i = Cells(Rows.Count, "o").End(xlUp).Row To 1 Step -2
Cells(i + 1, "o") = -Cells(i, "o")
Next
End Sub

--
Don Guillett
SalesAid Software

"andresg1975" wrote in message
...
can u tell me which 1 should i change to replace for my column I
thanks

"Don Guillett" wrote:

try this. Notice the step -2

Sub putnumbers()
For i = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -2
Cells(i + 1, 1) = -Cells(i, 1)
Next
End Sub

--
Don Guillett
SalesAid Software

"andresg1975" wrote in message
...
I didn't explain myself clear
the macro is only taking positive signs and converting them to minus
signs.
It should be a macro converting positive to minus, and minus to
positives.
thanks again.

at the end it shoul be like this

150
-150

-400
400

-250
250

150 change to -150, insert a row
-400 change to 400, insert a row

"Don Guillett" wrote:

change ,1 to ,"o"

Sub putnumbers()
For i = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
If Cells(i, 1) 0 Then Cells(i + 1, 1) = -Cells(i, 1)
Next i
End Sub

--
Don Guillett
SalesAid Software

"andresg1975" wrote in message
...
Can someone help me on this.
lets say i have

column O

row 1 150
row 2
row 3 92
row 4
row 5 70
row 6

how can i create a macro that goes to column O, enters the value of
the
cell
above in this case 150, one row below having opposite sign -150,
insert
a
row
below, and continue the same procedure. In this case, making 92
as -92
one
row below and insert a new row, and so on. Thanks a lot.










JLGWhiz

enter opposite number one row below
 
You need to find a column with continuous data to the last row and use that
on the For line:

Sub putnumbers()
For i = Cells(Rows.Count, 1).End(xlUp).Row To 1
Step -2

On this line you use the column number for the one you want to add the
opposite value. Change the "1" after the comma to the corresponding number
for A=1, B=2, C=3, etc.
Cells(i + 1, 1) = -Cells(i, 1)
Next
End Sub

Does this answer your question?


"andresg1975" wrote:

can u tell me which 1 should i change to replace for my column I
thanks

"Don Guillett" wrote:

try this. Notice the step -2

Sub putnumbers()
For i = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -2
Cells(i + 1, 1) = -Cells(i, 1)
Next
End Sub

--
Don Guillett
SalesAid Software

"andresg1975" wrote in message
...
I didn't explain myself clear
the macro is only taking positive signs and converting them to minus
signs.
It should be a macro converting positive to minus, and minus to positives.
thanks again.

at the end it shoul be like this

150
-150

-400
400

-250
250

150 change to -150, insert a row
-400 change to 400, insert a row

"Don Guillett" wrote:

change ,1 to ,"o"

Sub putnumbers()
For i = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
If Cells(i, 1) 0 Then Cells(i + 1, 1) = -Cells(i, 1)
Next i
End Sub

--
Don Guillett
SalesAid Software

"andresg1975" wrote in message
...
Can someone help me on this.
lets say i have

column O

row 1 150
row 2
row 3 92
row 4
row 5 70
row 6

how can i create a macro that goes to column O, enters the value of the
cell
above in this case 150, one row below having opposite sign -150, insert
a
row
below, and continue the same procedure. In this case, making 92 as -92
one
row below and insert a new row, and so on. Thanks a lot.









All times are GMT +1. The time now is 02:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com