I want to color the row corresponding to that cell after identifying the most data. For example, first, the highest amount of sales is identified, and next, the sales amount and the name of the person that are in one line are cut and transferred to another sheet. I am looking for a code to transfer 10% of the row's highest data to another sheet. In the first part of my code, the data is recognized correctly, but in the second part, where the data must be transferred to another sheet, the code doesn't run. Please help me.
I want 10% of the most data identified and cut from their row to another sheet.
Sub CopyHighlightedTransactions()
Dim mycell As Range
Dim myrange As Range
Dim lastrow As Long
Set myrange = Worksheets("sheet1").Range("b1:b1000")
myrange.Interior.Pattern = xlnon
For Each mycell In myrange
For i = 1 To 2
If mycell.Value = Application.WorksheetFunction.Large(myrange, i) Then
mycell.Interior.ColorIndex = 4
End If
Next
Next mycell
Dim TransIDField As Range
Dim TransIDCell As Range
Dim ATransWS As Worksheet
Dim HTransWS As Worksheet
Set ATransWS = Worksheets("sheet1")
Set TransIDField = ATransWS.Range("A2", ATransWS.Range("A2").End(xlDown))
Set TransIDField = myrange
Set HTransWS = Worksheets("sheet2")
For Each TransIDCell In TransIDField
If TransIDCell.Interior.ColorIndex = 4 Then
TransIDCell.Resize(1, 10).Copy Destination:= _
HTransWS.Range("A1").Offset(HTransWS.Rows.Count - 1, 0).End(xlUp).Offset(1, 0)
End If
Next TransIDCell
HTransWS.Columns.AutoFit
End Sub