ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro for Row Processing (https://www.excelbanter.com/excel-programming/363993-macro-row-processing.html)

George[_31_]

Macro for Row Processing
 
Can somebody please help this newbie

Each cell in A1:A10 contains an integer in descending order i.e. the highest
in row 1.

The integer in any row may be the same as the one above or below :e.g.:-

a1 = 34
a2 = 34
a3 = 32
a4 = 31
a5 = 31
a6 = 31
a7 = 25
a8 = 20
a9 = 20
a10 = 18

I need a macro that will remove duplicates and pull up the next highest
value to end up with :-

a1=34
a2=32
a3=31
a4=25
a5=20
a6=18

Please note that I do not want to delete rows containing duplicates as I
also need to repeat the whole process on B1:B10 and up to G1:G10 - all of
which contain
other (i.e. different) integers. Consequently, I would like to include that
feature in the macro.


Many thanks

George



Paul Mathews

Macro for Row Processing
 
Hi George, try this:

Sub MakeUniqueList()
'Create a list of unique items from an original data list whose
'first value occupies cell A1

Range("A1").Select

Do Until ActiveCell.Value = ""
If ActiveCell.Offset(1, 0).Value = ActiveCell.Value Then
Selection.Delete Shift:=xlUp
Else
ActiveCell.Offset(1, 0).Select
End If
Loop

End Sub

"George" wrote:

Can somebody please help this newbie

Each cell in A1:A10 contains an integer in descending order i.e. the highest
in row 1.

The integer in any row may be the same as the one above or below :e.g.:-

a1 = 34
a2 = 34
a3 = 32
a4 = 31
a5 = 31
a6 = 31
a7 = 25
a8 = 20
a9 = 20
a10 = 18

I need a macro that will remove duplicates and pull up the next highest
value to end up with :-

a1=34
a2=32
a3=31
a4=25
a5=20
a6=18

Please note that I do not want to delete rows containing duplicates as I
also need to repeat the whole process on B1:B10 and up to G1:G10 - all of
which contain
other (i.e. different) integers. Consequently, I would like to include that
feature in the macro.


Many thanks

George





All times are GMT +1. The time now is 09:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com