Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace duplicate values in Excel column range

Status
Not open for further replies.

jcw5107

Technical User
Jan 31, 2007
66
US
Hey now..!!
Below is sample code I'm working with.
It replaces duplicate values in a single column only, leaving the 1st row of duplicates.
I'm tryin' to make this work over several columns - columns B thru G to be exact.

Any suggestions or examples..!!
Thanks in advance..!!
jcw5107

Sub ReplaceDups()
Dim RowNdx As Long
Dim ColNum As Integer
ColNum = Selection(1).Column
For RowNdx = Selection(Selection.Cells.Count).Row To _
Selection(1).Row + 1 Step -1
If Cells(RowNdx, ColNum).Value = Cells(RowNdx - 1, ColNum).Value Then
Cells(RowNdx, ColNum).Value = "----"
End If
Next RowNdx
End Sub
 




Hi,

VBA question ought to be posted in Forum707.

Skip,

[glasses] To be safe on the [red]FOURTH[/red],
Don't take a [red]FIFTH[/red] on the [red]THIRD[/red]
Or you might not come [red]FORTH[/red] on the [red]FIFTH[/red]
[red][highlight blue]FORTH[/highlight][/red][white][highlight red]WITH[/highlight][/white] [tongue]
 
Ok - I'll post it there....
Any suggestions as to what I can do to get the code to work..?

Thanks..!
jcw5107
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top