montecarlo2012
Well-known Member
- Joined
- Jan 26, 2011
- Messages
- 984
- Office Version
- 2010
- Platform
- Windows
Hi, everyone.
I am trying to use if then else but results are wrong
on "B1" I just type "f" or "m" mean female or male and on c7 I want the constant divided by 2 for f, and by 3 for male, I tried this
I am trying to use if then else but results are wrong
on "B1" I just type "f" or "m" mean female or male and on c7 I want the constant divided by 2 for f, and by 3 for male, I tried this
HTML:
Option Explicit
Sub test()
Dim f As String, m As String
Dim constant As Integer
Dim result As Integer
Dim gender As String
gender = Range("b1").Value
constant = 500
f = Range("b1").Value
m = Range("b1").Value
If gender = f Then
result = constant / 2
Else
m = constant / 3
result = m
End If
Range("c7").Value = result
End Sub