VBA/UserForm: Find max, min value and less than 4000 in selected listbox items

ZerIo_0I

New Member
Joined
Dec 20, 2022
Messages
1
Office Version
  1. 2021
Platform
  1. Windows
Hello all
I really need your help as the topic title says I need to find the minimum, maximum, less than 4000 among the selected listbox items.
изображение_2022-12-21_013558745.png

UserForm.xlsm
AB
1EmployeeSalary
2Gilmore3440
3Stone6780
4Horton10244
5Rice5432
6McDaniel20544
7Fowler12322
8Paul5440
9Burns7656
10Robertson4568
UserForm

I already have a form, but I have no idea how to do those operations
Thank you in advance
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
I don't know your object names. So you have to replace them with the items on your form:

VBA Code:
Private Sub CalculateButton_Click() 'Must be original button name
  Dim listboxItems() As Long
  Redim listboxItems(ListBox1.ListCount-1) 'Must be original Listbox Name
  For i = 0 To ListBox1.ListCount-1
    listboxItems(i) = Val(ListBox1.List(i ))
  Next i
  If MinButton.Value Then 'Must be original radio button name
    TextBox1 = Application.WorksheetFunction.Min(listboxItems)
  End If
  If MaxButton.Value Then 'Must be original radio button name
    TextBox1 = Application.WorksheetFunction.Max(listboxItems)
  End If
  If lessThan400Button.Value Then 'Must be original radio button name
      For i = 0 To ListBox1.ListCount-1
        If listboxItems(i)<4000 Then
          TextBox1 = listboxItems(i)
          Exit For
        End If
    Next
  End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,728
Messages
6,180,598
Members
452,988
Latest member
wcself81

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top