Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default comparsions of columns and deletion


hi,

i want a macro for comparing columns.


for ex

A B C
1 1 1 .........
0 0 0 .........
1 0 0 .........
1 0 1 .........
........
..........
........


if A compared with B
11,00,10,10
so A is greater than B so column A should be deleted

like wise we have to compare each and every cell in the column
and compare all columns up to end of excel sheet

So,plz can any one help me regarding this

thanks
sree


--
sreedhar
------------------------------------------------------------------------
sreedhar's Profile: http://www.excelforum.com/member.php...o&userid=27582
View this thread: http://www.excelforum.com/showthread...hreadid=476492

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default comparsions of columns and deletion

Sub ABC()
Dim lastrow As Long, i As Long
Dim bGreater As Boolean
Dim j As Long
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
i = 1
Do While Cells(1, i + 1) < ""
bGreater = True
For j = 1 To lastrow
If Cells(j, i) < Cells(j, i + 1) Then
bGreater = False
Exit For
End If
Next
If bGreater Then
Columns(i).EntireColumn.Delete
Else
i = i + 1
End If
Loop
End Sub

--
Regards,
Tom Ogilvy

"sreedhar" wrote in
message ...

hi,

i want a macro for comparing columns.


for ex

A B C
1 1 1 .........
0 0 0 .........
1 0 0 .........
1 0 1 .........
.......
.........
.......


if A compared with B
11,00,10,10
so A is greater than B so column A should be deleted

like wise we have to compare each and every cell in the column
and compare all columns up to end of excel sheet

So,plz can any one help me regarding this

thanks
sree


--
sreedhar
------------------------------------------------------------------------
sreedhar's Profile:

http://www.excelforum.com/member.php...o&userid=27582
View this thread: http://www.excelforum.com/showthread...hreadid=476492



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default comparsions of columns and deletion


hi tom

u'r marco is comparing columns like this way

A compared B
B compared C
C compared D
D compared E and so on

but what i need is :

A should compare with B , if B is greater than A then B should be
deleted ,
and then A should compare with C if C is deleted
then should compare D and So on .
or
if A is greater than B, than A should be deleted,and next
B should compare with C and So on.

So,plz help me regrading this

thanks
sree


--
sreedhar
------------------------------------------------------------------------
sreedhar's Profile: http://www.excelforum.com/member.php...o&userid=27582
View this thread: http://www.excelforum.com/showthread...hreadid=476492

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default comparsions of columns and deletion

Sub ABC()
Dim lastrow As Long, i As Long
Dim bGreater As Boolean
Dim j As Long, k As Long
Dim lastcol As Long
lastcol = Cells(1, 256).End(xlToLeft).Column
lastrow = Cells(Rows.Count, 1).End(xlUp).Row
i = 1
Do While Cells(1, i + 1) < ""
For k = i + 1 To lastcol
bGreater = True
For j = 1 To lastrow
If Cells(j, i) < Cells(j, k) Then
bGreater = False
Exit For
End If
Next j
If bGreater Then Exit For
Next k
If bGreater Then
Columns(i).EntireColumn.Delete
Else
i = i + 1
lastcol = Cells(1, 256).End(xlToLeft).Column
End If
Loop
End Sub

--
Regards,
Tom Ogilvy


"sreedhar" wrote in
message ...

hi tom

u'r marco is comparing columns like this way

A compared B
B compared C
C compared D
D compared E and so on

but what i need is :

A should compare with B , if B is greater than A then B should be
deleted ,
and then A should compare with C if C is deleted
then should compare D and So on .
or
if A is greater than B, than A should be deleted,and next
B should compare with C and So on.

So,plz help me regrading this

thanks
sree


--
sreedhar
------------------------------------------------------------------------
sreedhar's Profile:

http://www.excelforum.com/member.php...o&userid=27582
View this thread: http://www.excelforum.com/showthread...hreadid=476492



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default comparsions of columns and deletion


hi tom

thanks a lot for u'r help


thanks
sree


--
sreedhar
------------------------------------------------------------------------
sreedhar's Profile: http://www.excelforum.com/member.php...o&userid=27582
View this thread: http://www.excelforum.com/showthread...hreadid=476492

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
#Ref! after row deletion Rick Excel Discussion (Misc queries) 3 March 19th 10 04:39 PM
name deletion rk0909 Excel Discussion (Misc queries) 2 January 4th 08 11:03 PM
simple row deletion lawson Excel Discussion (Misc queries) 3 October 17th 07 06:57 PM
Row Deletion Dan Excel Programming 3 September 1st 04 10:40 PM
How to detect a col/row deletion? Mauricio Villada Excel Programming 1 September 15th 03 08:53 PM


All times are GMT +1. The time now is 10:34 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"