LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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




 
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
Delete duplicate records from both columns cantab65 Excel Discussion (Misc queries) 2 March 19th 10 06:15 PM
Compare 2 columns and delete duplicate text MF Excel Worksheet Functions 1 December 4th 09 06:13 PM
Delete BOTH sets duplicate data in columns (debits/credits) Iamconstance Excel Worksheet Functions 1 June 12th 09 04:13 PM
Delete Columns with duplicate headers Casey[_99_] Excel Programming 0 June 2nd 06 08:26 PM
Delete Columns with duplicate headers Casey[_98_] Excel Programming 0 June 2nd 06 07:13 PM


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

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"