Thread
:
Delete Columns with duplicate headers
View Single Post
#
1
Posted to microsoft.public.excel.programming
Tom Ogilvy
external usenet poster
Posts: 6,953
Delete Columns with duplicate headers
For lCol = Columns("P").Column To Columns("L").Column Step -1
is the same as
for lCol = 16 to 12 step -1
confirming from the immediate window:
? columns("P").column
16
? columns("L").column
12
--
Regards,
Tom Ogilvy
"Ardus Petus" wrote:
Hi Casey
Sub DelDupeCols()
Dim lCol As Long
Dim rFound As Range
For lCol = Columns("P").Column To Columns("L").Column Step -1
Set rFound = Range(Range("K1"), Cells(1, lCol - 1)).Find( _
what:=Cells(1, lCol).Value, _
LookIn:=xlValues, _
lookat:=xlWhole)
If Not rFound Is Nothing Then
Columns(lCol).Delete
End If
Next lCol
End Sub
HTH
--
AP
"Casey" a écrit dans le
message de news:
...
Hi,
I have a range of column headers ("K1:IP1") that I would like to loop
through and find all duplicates. Then delete the entire column with the
duplicate header. I would like to keep the original header and column.
Example:
K L M N O
P..........................
Stone CMU Brick Grout Stone Stone
Columns O & P would be deleted but column K would remain.
--
Casey
------------------------------------------------------------------------
Casey's Profile:
http://www.excelforum.com/member.php...fo&userid=4545
View this thread:
http://www.excelforum.com/showthread...hreadid=547921
Reply With Quote
Tom Ogilvy
View Public Profile
Find all posts by Tom Ogilvy