G
Guest
Hi,
I have following code:
Sub MarkTheCells(SelRange As Range, worksheetname As String)
Dim l As Double, s As Double
Dim cell, SortRange As Range
Dim pos As Integer
Dim CellRow, CellCol As Long
pos = 0
SelRange.Interior.ColorIndex = xlNone
l = Application.Large(SelRange, 10)
s = Application.Small(SelRange, 10)
For Each cell In SelRange
If IsNumeric(cell) And _
Not IsEmpty(cell) And cell.Text <> "" Then
If cell.Value >= l Then
CellRow = cell.Row
CellCol = cell.Column
cell.Interior.ColorIndex = 3
Worksheets(worksheetname).Range("A1").Offset(20 + pos, 4).Value =
cell.Value
Worksheets(worksheetname).Range("A1").Offset(20 + pos, 3).Value =
Range("A1").Offset(CellRow - 1, 0).Value
Worksheets(worksheetname).Range("A1").Offset(20 + pos, 2).Value =
Range("A1").Offset(0, CellCol - 1).Value
pos = pos + 1
ElseIf cell.Value <= s Then
cell.Interior.ColorIndex = 5
End If
End If
Next
End Sub
This should select the 10 max and 10 min values in a selected range. It
should be possible to call it for different worksheets. But I get problems
with the Application.Large function. I can't find information on the
Application Methods.
Does anybody have an idea what to change in order to make this code work?
ANDY
I have following code:
Sub MarkTheCells(SelRange As Range, worksheetname As String)
Dim l As Double, s As Double
Dim cell, SortRange As Range
Dim pos As Integer
Dim CellRow, CellCol As Long
pos = 0
SelRange.Interior.ColorIndex = xlNone
l = Application.Large(SelRange, 10)
s = Application.Small(SelRange, 10)
For Each cell In SelRange
If IsNumeric(cell) And _
Not IsEmpty(cell) And cell.Text <> "" Then
If cell.Value >= l Then
CellRow = cell.Row
CellCol = cell.Column
cell.Interior.ColorIndex = 3
Worksheets(worksheetname).Range("A1").Offset(20 + pos, 4).Value =
cell.Value
Worksheets(worksheetname).Range("A1").Offset(20 + pos, 3).Value =
Range("A1").Offset(CellRow - 1, 0).Value
Worksheets(worksheetname).Range("A1").Offset(20 + pos, 2).Value =
Range("A1").Offset(0, CellCol - 1).Value
pos = pos + 1
ElseIf cell.Value <= s Then
cell.Interior.ColorIndex = 5
End If
End If
Next
End Sub
This should select the 10 max and 10 min values in a selected range. It
should be possible to call it for different worksheets. But I get problems
with the Application.Large function. I can't find information on the
Application Methods.
Does anybody have an idea what to change in order to make this code work?
ANDY