Jack-P-Winner
Member
I have a Macro that every time it does a new search it deletes the data from the "values found" sheet and places the new data on the new "values found" sheet. It is working great except 1 thing. It deletes my Conditional formatting every time it does a new search. I either need to figure out how to stop this from happening or add all my color coding to my Macro. I would appreciate any suggestions
Thanks!!
Here is the type formula I want to add. There are well over 100 rules like this
=AND(O2=2,O3=4,O4=4, O5=4, O6=4, O7=4, O8=4, O9=6) =$O$2:$O$2498
Here is my Macro
Thanks!!
Here is the type formula I want to add. There are well over 100 rules like this
=AND(O2=2,O3=4,O4=4, O5=4, O6=4, O7=4, O8=4, O9=6) =$O$2:$O$2498
Here is my Macro
Code:
Sub CopyMatches4()
Dim rngC As Range
Dim i As Long
Dim rStart As Long
Dim rFinish As Long
Dim rngPattern As Range
Dim shtWork As Worksheet
Dim shtPaste As Worksheet
Dim iCnt As Integer
Dim iBuffer As Integer
iBuffer = 10 'Rows above and below to copy, and to skip between blocks
iCnt = 0
Set shtWork = ActiveSheet
On Error Resume Next
Application.DisplayAlerts = False
Worksheets("Found Values").Delete
Application.DisplayAlerts = True
On Error GoTo 0
Worksheets.Add After:=Worksheets(Worksheets.Count)
Set shtPaste = Worksheets(Worksheets.Count)
shtPaste.Name = "Found Values"
shtWork.Activate
Set rngPattern = Application.InputBox("Select the pattern range(s)", Type:=8)
rStart = rngPattern.Cells(rngPattern.Cells.Count).Row + 1
rFinish = rngPattern.Parent.UsedRange.Cells(rngPattern.Parent.UsedRange.Cells.Count).Row
For i = rStart - rngPattern.Cells(1).Row To rFinish
For Each rngC In rngPattern
If rngC.Offset(i).Value <> rngC.Value Then
GoTo CheckNext
End If
Next rngC
rngPattern.Offset(i).BorderAround xlContinuous, xlThick
rngPattern.Offset(i - iBuffer).Resize(rngPattern.Rows.Count + iBuffer * 2).EntireRow.Copy _
shtPaste.Range("A2").Offset(iCnt * (rngPattern.Rows.Count + iBuffer * 2)).Offset(iCnt * iBuffer).Resize(rngPattern.Rows.Count + iBuffer * 2).EntireRow
iCnt = iCnt + 1
rngPattern.Offset(i).Select
CheckNext:
Next i
With shtPaste
.Range("B:B,D:D,F:F,H:H,K:K,N:N,P:P,S:S,V:V,AA:AA,AD:AD,AG:AG,AJ:AJ").ColumnWidth = 0.35
.Range("I:J,L:M,O:O,Q:R,T:U").ColumnWidth = 3.5
.Range("W:Z,AB:AC").ColumnWidth = 3#
.Range("E:E").ColumnWidth = 18.5
.Range("AE:AF,AH:AI").ColumnWidth = 5
End With
End Sub