Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default 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.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default 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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default 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.




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default 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.









  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default 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.







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
enter a number if equal to another number malik Excel Discussion (Misc queries) 4 February 13th 09 12:40 AM
Why am I getting ### when I enter an accting number and hit enter CC Mac New Users to Excel 1 December 15th 08 09:14 PM
when I enter a number, only ###### shows? Greg's excel questions Excel Worksheet Functions 3 July 30th 08 02:37 AM
Always enter number as a decimal <1 michaelberrier Excel Discussion (Misc queries) 11 September 30th 06 04:53 PM
enter 2 values in opposite corners of a cell itsthebike Excel Discussion (Misc queries) 1 September 23rd 05 07:36 PM


All times are GMT +1. The time now is 05:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"