Smarter if-sentence?

Stevenn

Active Member
Joined
Feb 8, 2012
Messages
259
Can I write this smarter? Maybe a select case-statement?

Code:
If A Then
    Let MethodType = 0
ElseIf B Then
    Let MethodType = 1
ElseIf C Then
    Let MethodType = 2
End If
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Actually, it should be radio buttons in a UserForm. I have 3 buttons, and whether the user have clicked on the first, second or third button it will determine the MethodType to be 0, 1, or 2. So in my example A, B, and C will just be Me.btnFirstMethod.Value etc. And their values will be true if they were selected.
 
Upvote 0
I think that if there is a regule between the Values of Me. (for example the Values are equal to 3, 7, 17) then Your Code can look like this:
Code:
MethodType = Int(Me.btnFirstMethod.Value / 7)
Best regards.
 
Last edited:
Upvote 0
But I have 3 different radio buttons: btnFirstMethod, btnSecondMethod, and btnThirdMethod. And depending on which button the user have clicked I want to determine the MethodType variable.
 
Upvote 0
So,
try change words First, Second, Third on the analogous numeric Values: 1, 2, 3 and try using the code:
Code:
Right(Replace(Application.Caller, "Method", ""), 1)-1
Best regards.
 
Upvote 0

Forum statistics

Threads
1,215,467
Messages
6,124,984
Members
449,201
Latest member
Lunzwe73

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