1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
Private Sub CommandButton1_Click()
Dim var As String
MsgBox "imc =" & Chr(10) & Val(TextBox2 / (TextBox1 / 100) ^ 2) & Range("w1")
MsgBox IMC(Worksheets("Feuil1"))
End Sub
Function IMC(Fe As Worksheet) As String
Dim Plage As Range
Dim Cel As Range
Dim Lig As Long
With Fe: Set Plage = .Range(.Cells(3, 1), .Cells(.Rows.Count, 1).End(xlUp)): End With
Set Cel = Plage.Find(Int(TextBox1.Text), , xlValues, xlWhole)
If Not Cel Is Nothing Then
Lig = Cel.Row
With Fe: Set Plage = .Range(.Cells(Lig, 2), .Cells(Lig, .Columns.Count).End(xlToLeft)): End With
End If
Set Cel = Plage.Find(Int(TextBox2.Text), , xlValues, xlWhole)
If Not Cel Is Nothing Then
IMC = Fe.Cells(1, IIf(Fe.Cells(1, Cel.Column).Value = "", Cel.Column - 1, Cel.Column)).Value
End If
End Function |
Partager