A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

find and move values 0



 
 
Thread Tools Display Modes
  #1  
Old September 26th, 2008, 09:13 PM posted to microsoft.public.excel.worksheet.functions
Sojo
external usenet poster
 
Posts: 21
Default find and move values 0

I am writing a macro to automate several processes. I have the following
table where column A has positive and negative values and column B is blank.
I need a formula that will find all the negative values in column A and move
them to column B. In essence, it needs to say if number in column A 0,
then cut it and paste it into column B.

A B
1. Original Negative
2. 3.72545
3. 3.4584
4. 3.1071
5. -0.460399
6. -0.803222
7. -1.12457


  #2  
Old September 26th, 2008, 09:37 PM posted to microsoft.public.excel.worksheet.functions
MuppetMan
external usenet poster
 
Posts: 5
Default find and move values 0

Put into B2:
=if(A20,A2,"")

Copy down as far as you need. You can use a formula in one cell to
clear the contents of another cell.

However, I think you could use custom formatting to hide negative
values in column A.

Muppet Man


On Sep 26, 9:13*pm, Sojo wrote:
I am writing a macro to automate several processes. *I have the following
table where column A has positive and negative values and column B is blank. *
I need a formula that will find all the negative values in column A and move
them to column B. *In essence, it needs to say if number in column A 0,
then cut it and paste it into column B.

* * * * *A * * * * * * * * *B
1. * Original * * Negative
2. * 3.72545 * *
3. * 3.4584 * *
4. * *3.1071 * *
5. -0.460399 * *
6. -0.803222 * *
7. -1.12457 * *


  #3  
Old September 26th, 2008, 09:37 PM posted to microsoft.public.excel.worksheet.functions
muddan madhu
external usenet poster
 
Posts: 695
Default find and move values 0

may be this ??

in col B put this forumula =IF(B20,"",B2)

select the col A & then go format | conditinal format | choose formula
is :=B2=C2 | format | font tab | choose the white color | ok | ok


On Sep 26, 4:13*pm, Sojo wrote:
I am writing a macro to automate several processes. *I have the following
table where column A has positive and negative values and column B is blank. *
I need a formula that will find all the negative values in column A and move
them to column B. *In essence, it needs to say if number in column A 0,
then cut it and paste it into column B.

* * * * *A * * * * * * * * *B
1. * Original * * Negative
2. * 3.72545 * *
3. * 3.4584 * *
4. * *3.1071 * *
5. -0.460399 * *
6. -0.803222 * *
7. -1.12457 * *


  #4  
Old September 26th, 2008, 09:37 PM posted to microsoft.public.excel.worksheet.functions
IanC
external usenet poster
 
Posts: 69
Default find and move values 0

For r = 2 To 100
If Cells(r, 1).Value 0 Then
Cells(r, 1).Copy
Cells(r, 2).PasteSpecial
Cells(r, 1).Value = ""
End If
Next

--
Ian
--
"Sojo" wrote in message
...
I am writing a macro to automate several processes. I have the following
table where column A has positive and negative values and column B is
blank.
I need a formula that will find all the negative values in column A and
move
them to column B. In essence, it needs to say if number in column A 0,
then cut it and paste it into column B.

A B
1. Original Negative
2. 3.72545
3. 3.4584
4. 3.1071
5. -0.460399
6. -0.803222
7. -1.12457




  #5  
Old September 26th, 2008, 09:38 PM posted to microsoft.public.excel.worksheet.functions
muddan madhu
external usenet poster
 
Posts: 695
Default find and move values 0

sorry !!!


in col B put this forumula =IF(A20,"",A2)


select the col A & then go format | conditinal format | choose
formula
is :=B2=C2 | format | font tab | choose the white color | ok | ok





On Sep 26, 4:13*pm, Sojo wrote:
I am writing a macro to automate several processes. *I have the following
table where column A has positive and negative values and column B is blank. *
I need a formula that will find all the negative values in column A and move
them to column B. *In essence, it needs to say if number in column A 0,
then cut it and paste it into column B.

* * * * *A * * * * * * * * *B
1. * Original * * Negative
2. * 3.72545 * *
3. * 3.4584 * *
4. * *3.1071 * *
5. -0.460399 * *
6. -0.803222 * *
7. -1.12457 * *


  #6  
Old September 26th, 2008, 10:53 PM posted to microsoft.public.excel.worksheet.functions
Sojo
external usenet poster
 
Posts: 21
Default find and move values 0

Thanks for all the post. However, I did not add that my columns run from A
to DO (this will be constant) and row go to 2280 (this will not be contant).
So, I think IanC's idea of a macro would be easier.

I copied and pasted the macro as is into a VB module, but it didn't work. I
don't know much about code, so can't figure out what I did wrong.

Any thoughts?


"IanC" wrote:

For r = 2 To 100
If Cells(r, 1).Value 0 Then
Cells(r, 1).Copy
Cells(r, 2).PasteSpecial
Cells(r, 1).Value = ""
End If
Next

--
Ian
--
"Sojo" wrote in message
...
I am writing a macro to automate several processes. I have the following
table where column A has positive and negative values and column B is
blank.
I need a formula that will find all the negative values in column A and
move
them to column B. In essence, it needs to say if number in column A 0,
then cut it and paste it into column B.

A B
1. Original Negative
2. 3.72545
3. 3.4584
4. 3.1071
5. -0.460399
6. -0.803222
7. -1.12457





  #7  
Old September 27th, 2008, 03:02 PM posted to microsoft.public.excel.worksheet.functions
IanC
external usenet poster
 
Posts: 69
Default find and move values 0

You don't say whether anything at all happened, so I apologiose if I'm
telling you here what you already know.

You need to wrap it in a subroutine:

Sub MoveNegatives()
For r = 2 To 100
If Cells(r, 1).Value 0 Then
Cells(r, 1).Copy
Cells(r, 2).PasteSpecial
Cells(r, 1).Value = ""
End If
Next
End Sub

You then need to run the macro. You can either do it in the VB editor (make
sure the flashing cursor in somewhere in the routine the click the Run
button or press F5), or you can do it from within Excel by going Tools
Macro Macros, highlighting the macro name and clicking "Run".

You said your data runs from columns A to DO. Do you mean you need to move
the negative numbers from column A to column DO? If so, change the number in
the PasteSpecial line from 2 to 119. You can find the column number of any
column using the columns keyword eg in any cell type =COLUMNS(DO1). The
returned number is the column number.

You said your data occupies a varying number of rows.

Assuming I am right in thinking you need to move the negative numbers from A
to DO, the data starts in row 2 and there are no blank rows in the data, the
following code should do.

Sub MoveNegatives()
' For row numbers 2 to last occupied row
For r = 2 To Cells.SpecialCells(xlCellTypeLastCell).Rows
' check value of cell in column A
If Cells(r, 1).Value 0 Then
' if cell value is 0 or greater, jump to End If, otherwise step onto
next line
' copy contents of cell in column A
Cells(r, 1).Copy
' paste contents to cell in column DO
Cells(r, 119).PasteSpecial
' delete contents of cell in column A
Cells(r, 1).Value = ""
End If
' returns to the For line and increases r by 1
Next
End Sub

--
Ian
--
"Sojo" wrote in message
...
Thanks for all the post. However, I did not add that my columns run from
A
to DO (this will be constant) and row go to 2280 (this will not be
contant).
So, I think IanC's idea of a macro would be easier.

I copied and pasted the macro as is into a VB module, but it didn't work.
I
don't know much about code, so can't figure out what I did wrong.

Any thoughts?


"IanC" wrote:

For r = 2 To 100
If Cells(r, 1).Value 0 Then
Cells(r, 1).Copy
Cells(r, 2).PasteSpecial
Cells(r, 1).Value = ""
End If
Next

--
Ian
--
"Sojo" wrote in message
...
I am writing a macro to automate several processes. I have the
following
table where column A has positive and negative values and column B is
blank.
I need a formula that will find all the negative values in column A and
move
them to column B. In essence, it needs to say if number in column A
0,
then cut it and paste it into column B.

A B
1. Original Negative
2. 3.72545
3. 3.4584
4. 3.1071
5. -0.460399
6. -0.803222
7. -1.12457







 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:15 AM.


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