Hello,
Can someone take a look at this coding and tell me why it makes some of the information I'm trying to sort disappear?
Option Explicit
Sub o2Match_Horses()
'
' o2MatchHorses Macro
'
' Match horses that are highlighted in Column D to the highlighted horses in Column K.
'
' Keyboard Shortcut: Ctrl+Shift+B
'
Dim LR As Long
Dim Rng As Range, cel As Range, c As Range
Dim ws As Worksheet
Set ws = Sheets("Sheet1")
Application.ScreenUpdating = False
With ws
LR = .Range("D" & .Rows.Count).End(xlUp).Row
Set Rng = .Range(.Cells(1, "D"), .Cells(LR, "D"))
Rng.AutoFilter Field:=1, Operator:=xlFilterNoFill
.Range(.Cells(2, "L"), .Cells(LR, "L")).SpecialCells(xlCellTypeVisible).Value = "x"
.AutoFilterMode = False
Set Rng = .Range(.Cells(2, "D"), .Cells(LR, "D"))
For Each cel In Rng
'If Not .Cells(cel.Row, "L").Value = "x" Then
'If Not Trim(cel.Value) = Trim(.Cells(cel.Row, "K").Value) Then
Set c = .Columns(11).Find(cel.Value, LookIn:=xlValues)
'If Not c Is Nothing Then
'.Range(.Cells(cel.Row, "E"), .Cells(cel.Row, "K")).Value = .Range(.Cells(c.Row, "E"), .Cells(c.Row, "K")).Value
'End If
'End If
'End If
Next cel
'.Columns(12).ClearContents
End With
Application.ScreenUpdating = True
End Sub
Attached is a sample you can use to show you what I mean and hopefully fix it to where it doesn't delete information.
CheerZ!
Wyldjokre69
Sample11062014.xlsb
P.s: the code takes the highlighted horses in Cells D & K and matches them up including the data in Cells E-O. Apply and see for yourself. If you can add a piece of coding which will keep the data that is not highlighted in pink and have it just match across all between E-O, that would be super.
Bookmarks