If, ElseIf statements (multiple)

Formula11

Active Member
Joined
Mar 1, 2005
Messages
468
Office Version
  1. 365
Platform
  1. Windows
Is it possible to have an ElseIf statement on a single line?
An example is shown but each statement is on two lines.

Tried the following but did not work.

VBA Code:
If IsInArray(Character, Array01) = True Then: Increment = 1


VBA Code:
Function Size(Character As String) As Double
    Dim Increment As Double
    If IsInArray(Character, Array01) = True Then
        Increment = 1
    ElseIf IsInArray(Character, Array02) = True Then
        Increment = 1
    ElseIf IsInArray(Character, Array03) = True Then
        Increment = 5 / 6
    ElseIf IsInArray(Character, Array04) = True Then
        Increment = 2 / 3
    ElseIf IsInArray(Character, Array05) = True Then
        Increment = 1 / 2
    ElseIf IsInArray(Character, Array07) = True Then
        Increment = 1 / 3
    ElseIf IsInArray(Character, Array08) = True Then
        Increment = 1 / 6
    Else
        Increment = 1
    End If
    Size = Increment
End Function
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
You could us a Select Case statement like
VBA Code:
   Select Case True
      Case IsInArray(Character, Array01): Increment = 1
      Case IsInArray(Character, Array02): Increment = 1
      Case IsInArray(Character, Array03): Increment = 5 / 6
   End Select
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,889
Messages
6,181,608
Members
453,055
Latest member
cope7895

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