Enum not returning expected value

confusion123

Active Member
Joined
Jul 27, 2014
Messages
400
Code:
Enum Fruit

Apple = 1
Orange = 2

End Enum

Sub Start

If Cells(1, 1).Value = Fruit.Apple Then
    Cells(10, 10) = 1
Else
    Cells(10, 10) = 2
End If

End Sub

If cell(1,1) = Apple, I want cell(10,10) to return 1 but it seems cell(1,1) has to be 1 for cell(10,10) to return a value of 1.

Do I have to convert the enum value or something?
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
An Enum is just a predefined constant (number) - you can't compare it to the text "Apple" if that's what you mean.
 
Upvote 0

Forum statistics

Threads
1,214,861
Messages
6,121,969
Members
449,059
Latest member
oculus

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