# Math Issue

#### rockchalk33

##### Board Regular
Hey all so I had recently finished up a job and the recipient had emailed me and showed that there is a problem with my multiplication. I'm on my way to troubleshoot now but here's the issue. Assume a rate of \$10/hour. There is a textbox to enter how many hours a particular person had worked. The Userform then takes the textbox value and multiplies it by the \$10/hour rate and puts that product into column B. Obviously this is a variable range but below is an example of what the code looks like:

Range("B2") = TextBox1.Value * 10

Seems fairly straightforward except if this person works in half hour increments (example would be 10.5 hours)...the math doesn't recognize the 0.5 hour increment and would instead give a value of \$100 instead of \$105.

I am on my way to troubleshoot now, can anyone give a rough estimate as to what might be causing this problem?

### Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Hi,
you need to deklare a varible with double instead of integer then it will reconize the 10.5

Hey all so I had recently finished up a job and the recipient had emailed me and showed that there is a problem with my multiplication. I'm on my way to troubleshoot now but here's the issue. Assume a rate of \$10/hour. There is a textbox to enter how many hours a particular person had worked. The Userform then takes the textbox value and multiplies it by the \$10/hour rate and puts that product into column B. Obviously this is a variable range but below is an example of what the code looks like:

Range("B2") = TextBox1.Value * 10

Seems fairly straightforward except if this person works in half hour increments (example would be 10.5 hours)...the math doesn't recognize the 0.5 hour increment and would instead give a value of \$100 instead of \$105.

I am on my way to troubleshoot now, can anyone give a rough estimate as to what might be causing this problem?

Good afternoon Rockchalk,

It seems you've declared TextBox1 an Integer. In the case of 10.5, it'll automatically make it 10 and therefore you'll receive the answer of 100.

In your coding, you should see: Dim TextBox1 as Integer
Change that to this: Dim TextBox1 as Double

Hey all so I had recently finished up a job and the recipient had emailed me and showed that there is a problem with my multiplication. I'm on my way to troubleshoot now but here's the issue. Assume a rate of \$10/hour. There is a textbox to enter how many hours a particular person had worked. The Userform then takes the textbox value and multiplies it by the \$10/hour rate and puts that product into column B. Obviously this is a variable range but below is an example of what the code looks like:

Range("B2") = TextBox1.Value * 10

Seems fairly straightforward except if this person works in half hour increments (example would be 10.5 hours)...the math doesn't recognize the 0.5 hour increment and would instead give a value of \$100 instead of \$105.

I am on my way to troubleshoot now, can anyone give a rough estimate as to what might be causing this problem?
Off the top of my head, I expect you will find the Cell Format for cell B2 to be Number with zero decimal places or Custom Formatted as # or 0.

Edit Note: Or you will find the column width is too narrow to show the decimal place.

Last edited:
Awesome! I'll be sure to check all the above!

Replies
1
Views
239
Replies
4
Views
430
Replies
5
Views
309
Replies
2
Views
468
Replies
6
Views
353

1,203,076
Messages
6,053,396
Members
444,661
Latest member
liamoohay

### 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?

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