Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default New Excel user needs help with simple Macro...

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.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default New Excel user needs help with simple Macro...

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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
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.



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
Simple Excel Macro TimWillDoIt New Users to Excel 5 April 25th 07 06:17 PM
Simple IF Statement Q - Ditzy User bleu808 Excel Discussion (Misc queries) 1 January 13th 06 12:34 AM
New Excel user needs help with simple Macro... Rahim Kassam New Users to Excel 1 January 24th 05 02:10 PM
simple excel vba macro Andrew Slentz Excel Programming 4 May 21st 04 08:57 AM
Simple Excel Macro - Please Help Curious[_3_] Excel Programming 7 October 23rd 03 04:26 PM


All times are GMT +1. The time now is 08:20 PM.

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"