PDA

View Full Version : Solved: how to check duplication of columns?



maryam
04-19-2007, 04:52 AM
in a worksheet we have different column and the first row (A1 to IV1) contains the title of each column. How can we check duplication and delete the duplicated column if it exists? it column A and column C are the same for example I want to delete the first one, Column A.

Simon Lloyd
04-19-2007, 05:24 AM
You need to be a bit more explanitary!, do you just want to delete the column based on a duplication of title? or on duplication of contents?

Again i would urge you to explain in more detail and where possible supply a sample workbook with more detail than the one you supplied with the textbox problem!

Regards,
Simon

maryam
04-19-2007, 05:35 AM
based on the title. I am sorry than I cannot explain well. I attach an excel sheet to this post to explain better. Here I want to delete column B as column B and F have same title and B is first.

maryam
04-23-2007, 09:23 PM
anr reply?

Haldun
04-24-2007, 12:58 AM
Hi,

Use following macro...

Sub DelColDups()
Dim Rng As Range
Dim Cll As Range
Set Rng = Range("1:1")
For Each Cll In Rng
If WorksheetFunction.CountIf(Rng, Cll.Value) > 1 Then
Cll.EntireColumn.Delete
End If
Next
End Sub