I am trying to populate a userform with numbers bigger than ten and smaller than zero.
I got help with the code below that populates labels 44 to 63 with those numbers (from column "S").
But I am also trying to populate labels 2 to 21 with an offset of those numbers bigger than ten and smaller than zero from column "B"
and
labels 23 to 42 with an offset from column D.
I have been stuck trying to figure out how to offset Application.Max. The closest thing I got to working was
MyArray = Range("S4:S" & lrow).Offset(0,-15).Value
but it only works with numbers.
Thanks for your help.
Private Sub UserForm_Activate()
Dim i As Integer
Dim ws As Worksheet
Set ws = ActiveSheet
Dim erange As Range
Dim lrow As Long
lrow = Range("S" & Rows.Count).End(xlUp).Row
Count = Application.CountIf(Range("S:S"), ">10")
MyArray = Range("S4:S" & lrow).Value
Entrycount = Application.Min(Count - 1, 19)
For i = 44 + Entrycount To 44 Step -1
M = Application.Max(MyArray)
P = Application.Match(M, MyArray, 0)
MyArray(P, 1) = 0
Me.Controls("Label" & i).Caption = M
Next
Count2 = Application.CountIf(Range("S:S"), ">10")
lrow = Range("S" & Rows.Count).End(xlUp).Row
Count = Application.CountIf(Range("S:S"), "<0")
MyArray = Range("S4:S" & lrow).Value
Entrycount = Application.Min(Count - 1, 19)
For i = (44 + Count2) + Entrycount To (44 + Count2) Step -1
M = Application.Min(MyArray)
P = Application.Match(M, MyArray, 0)
MyArray(P, 1) = 0
Me.Controls("Label" & i).Caption = M
Next
End Sub
Bookmarks