Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Looping and deleting thru cells which values offset

I have a large file, part number in column A and dollars in column B. I need
to delete all the transactions related to the same part which value is an
offset of another transaction.

When I sort it by Absolute number, itll put the negatives quantities first
and then the positive. When there are single occurrences for both cases
(+/-), I can delete them easily. The problem arises when I have lets say
groups of 3 negatives and 3 positives or even worse 3 negatives and 4
positives. There is no other field to associate them for sorting.

Any thoughts?







Sub offset()

For j = ActiveSheet.Cells(Rows.count, "A").End(xlUp).Row To 2 Step -1

If Cells(j,1).Value = Cells(j - 1, 1).Value Then

If Cells(j, 2).Value = -1 * (Cells(j - 1, 2).Value) Then

Cells(j, 1).Rows.EntireRow.Delete

End If

End If

Next j

End Su

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 515
Default Looping and deleting thru cells which values offset

=IF(B1<0,1,2) in Col C will mark all negative numbers as 1 and positives as
2. A sort on col C will put all negatives first, bundled together. Could
that help you?

--
Hth

Kassie Kasselman
Change xxx to hotmail


"LuisE" wrote:

I have a large file, part number in column A and dollars in column B. I need
to delete all the transactions related to the same part which value is an
offset of another transaction.

When I sort it by Absolute number, itll put the negatives quantities first
and then the positive. When there are single occurrences for both cases
(+/-), I can delete them easily. The problem arises when I have lets say
groups of 3 negatives and 3 positives or even worse 3 negatives and 4
positives. There is no other field to associate them for sorting.

Any thoughts?







Sub offset()

For j = ActiveSheet.Cells(Rows.count, "A").End(xlUp).Row To 2 Step -1

If Cells(j,1).Value = Cells(j - 1, 1).Value Then

If Cells(j, 2).Value = -1 * (Cells(j - 1, 2).Value) Then

Cells(j, 1).Rows.EntireRow.Delete

End If

End If

Next j

End Su

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
looping through an giving values to cells in vba DowningDevelopments Excel Discussion (Misc queries) 3 August 25th 06 12:39 AM
Looping thru values in a Range of Cells PP Excel Programming 2 July 29th 05 04:12 PM
Looping and Offset Arturo Excel Programming 2 November 17th 04 02:43 AM
Deleting some cells in a row using command button and offset Marvin Excel Programming 3 April 6th 04 02:36 AM
Deleting blanks from the end of values in cells Gord Dibben Excel Programming 0 April 1st 04 01:37 AM


All times are GMT +1. The time now is 03:40 AM.

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

About Us

"It's about Microsoft Excel"