converting a double to a long

vbanative

New Member
Joined
Mar 30, 2013
Messages
8
I am trying to convert a double to a long using:

CLng(test)

However, when I run it I get an overflow error. The reason I need to convert 'test' to a long is because I want to use the And operator in the following way:

truth = (test and &H1F)

Where truth is a long. Any suggestions?
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
I am trying to convert a double to a long using:

CLng(test)

However, when I run it I get an overflow error. The reason I need to convert 'test' to a long is because I want to use the And operator in the following way:

truth = (test and &H1F)

Where truth is a long. Any suggestions?
Maybe round it to 0 decimal places:
test = WorksheetFunction.Round(test, 0)
 
Upvote 0
I am trying to convert a double to a long using:

CLng(test)

However, when I run it I get an overflow error. The reason I need to convert 'test' to a long is because I want to use the And operator in the following way:

truth = (test and &H1F)

Where truth is a long. Any suggestions?

What is the Double value that is giving you the problem?
 
Upvote 0

Forum statistics

Threads
1,203,502
Messages
6,055,772
Members
444,822
Latest member
Hombre

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