VBA and Boolean data types

jaustin

New Member
Joined
Jun 6, 2017
Messages
29
I used a data source that used a True/False variable. I replaced True with 1 and False with 0.001. I wanted to do regression which does not accept zeroes. This has worked well for several years and regression has worked with this variable. All of a sudden I am trying to use this variable with VBA and finding out that when trying to do calculations or filters to select specific rows that the underlying values are -1. I've researched and found that when replacing Booleans variables with numbers that the value is replaced with a -1. I don't understand why this issue has not been noticed previously, but it may be the first time I was using the variable in a "If(ppool = " (I've tried 0, 1, 001, True, False) but am finding that the underlying value is always -1. I've tried different formats but nothing has changed this condition. As noted, I've tried going back to True/False but VBA still looks at the variable as -1. If I could return to True/False I've seen where you can change to 1 and 0 (which I could use) but apparently once you have added a number to the variable you get -1 regardless. I can change the "displayed" value but cannot do anything that used the basic value (except regression accepts the 1 and 0.001 displayed values as 1 and 0.001. I can copy and paste/display the 0.001. value but when doing a PPool = ActiveCell.Select it is -1.

Retreating to the original data source would be a major re-structuring to the project.

Any suggestions? Thanks in advance.

Jaustin
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
It would be helpful if you can post your functions. In VBA a numeric of zero is FALSE, and everything greater or less than zero will implicitly cast to TRUE. From what you have posted, I don't see any reason why you cannot use an alternative integral type or create your own type if necessary. Please post your code.
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,917
Members
449,093
Latest member
dbomb1414

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