if then ... with F8 I see a jump

montecarlo2012

Well-known Member
Joined
Jan 26, 2011
Messages
984
Office Version
  1. 2010
Platform
  1. Windows
Hello, I hope some advice, when I debug this code with f8 when the yellow line got at the conditional statement .... if then..... I see a little jump, I mean the code work until get here to the if then statement.
Code:
Private Sub CommandButton1_Click()
Dim gender As String '[1]
Dim weight As Double '[2]
Dim height As Double '[3]
Dim age As Double    '[4]
Dim bmi As Double '..............[5]
Dim waist As Single '............[6]
Dim idealwaist As Integer '......[7]
Dim idealtights As Integer '.....[8]
Dim bmr As Integer '.............[9]
gender = Range("A10") '...........[10]
weight = Range("B2")
height = Range("B3")
age = Range("B1")
idealwaist = (Range("B3") * 12) * 0.47
bmi = (Range("b2") * 4.88) / (Range("B3").Value) ^ 2
Select Case bmi
        Case Is < 15
            Cells(5, 2) = "very severely underweight"
        Case 15 To 15.9999
            Cells(5, 2) = "Severely underweight"
        Case 16 To 18.4999
            Cells(5, 2) = "underweight"
        Case 18.5 To 24.9999
            Cells(5, 2) = "Normal (healthy weight)"
        Case 25 To 29.9999
            Cells(5, 2) = "Overweight"
        Case 30 To 34.9999
            Cells(5, 2) = "Obese class I ( normal obese)"
        Case 35 To 39.9999
            Cells(5, 2) = "obese class II (moderate )"
        Case Is > 40
            Cells(5, 2) = "Obese Class III (Very severely obese)"
    End Select
    If Range("A10").Value = 1 Then
  bmr = 447.593 + (9.247 * Range("B2").Value) + (3.098 * Range("B3").Value) - (5.677 * Range("B1").Value)
        ElseIf Range("A10").Value = 2 Then
        bmr = 88.362 + (13.397 * Range("B2").Value) + (4.799 * Range("B3").Value) - (5.677 * Range("B1").Value)
End If
Range("B4") = Round(bmi, 1)
Range("B6") = idealwaist
Range("B6") = idealwaist
Range("B7") = idealtights
Range("d1") = bmr
End Sub

HTML:
            age   34           weight in   pounds   143           height   5.3           bmi   24.8           you are   Normal (healthy   weight)           ideal waist   30           ideal tights   0           bmr                               gender   1           female = 1 ►   male = 2
 
Last edited:

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
When F8 comes to a conditional, it evaluates the condition and branches to the appropriate line of code, skipping the lines that aren't excicuted.
 
Upvote 0
after your advice, I discover my first variable was completely wrong declare, and so on, thanks MIKERICKSON.
 
Upvote 0

Forum statistics

Threads
1,216,126
Messages
6,129,004
Members
449,480
Latest member
yesitisasport

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