View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Myrna Larson Myrna Larson is offline
external usenet poster
 
Posts: 863
Default New Excel user needs help with simple Macro...

PS: The problem with your idea of replacing the numbers with an X is that you
can't write a statement analogous to "If A = -B" when one or the other (or
both) is text. You'd have to add additional code to determine that both values
are numbers before you try the comparison. If you must replace the existing
data, you should replace it with a number that is doesn't occur in the data
itself.

BTW, the code I posted checks data in column A. You may need to change that.


On Sun, 23 Jan 2005 21:58:06 -0600, Myrna Larson
wrote:

If you don't want to compare the cell above a deleted pair of rows with the
cell below that pair, I believe you could do something like this


Dim R As Long

With ActiveSheet
R = .Cells(.Rows.Count, 1).End(xlUp).Row - 1
Do While R = 1
If .Cells(R, 1).Value = -.Cells(R + 1, 1).Value Then
.Rows(R).Resize(2).EntireRow.Delete
R = R - 2
Else
R = R - 1
End If
Loop
End With


On Sun, 23 Jan 2005 22:34:34 -0500, "Rahim Kassam"
wrote:

Hello,

I am relatively need to Microsoft Excel and I need help creating a simple
Macro.

I would like to create a Macro that will:

- take the value of the selected value
- add it to the value of the cell below it
- if the sum of these two cells is zero - replace values of both cells with
an x
- move to the next set of cells in the same column repeat the procedure
- continue the procedure for the entire column
- once that is done, for each cell with an x delete the entire row

the reason why I do not wish to delelte the rows on the fly is because it is
possible that after a deletion of a pair, the value of the cell above it and
the value of the cell below could also sum to zero but I would want to keep
these.

I have tried to accomplish this with the use of the Macro recorder and VBA
in Excel 2000 but have been thus far unsuccessful, any help would be much
appreciated.

Thanks in advance.

R.