VBA - Manimum Number

Enter your search terms Submit search form





In the program, I will show you how to find minimum value out of a range of cells that are entered through four text boxes.

You need to insert four text boxes, a label button and also a command button. To key in the codes, click on the command button and go into the Visual Basic Editor. To find the maximum value, you can use the Max function.

Private Sub CommandButton1_Click()
Cells(1, 1).Value = Val(TextBox1.Text)
Cells(2, 1).Value = Val(TextBox2.Text)
Cells(3, 1).Value = Val(TextBox3.Text)
Cells(4, 1).Value = Val(TextBox4.Text)
Cells(5, 1).Formula = "=Min(A1:A4)"
Label1.Caption = Cells(5, 1).Value
End Sub







 [Back to VBToday]