Formatting decimal places

tnapele

New Member
Joined
Mar 27, 2020
Messages
14
Office Version
  1. 365
Platform
  1. Windows
Hello!

I have a excel worksheet that uses Vlookups in the cells of the worksheet to plug data into a userform. The Vlookups get the data from a separate worksheet that has a ton of decimals (ie. 2500.7256416436) but I would like to change specific ones to have 2 decimals and others to have no decimals. Is there a way I can do this?
I have tried to format the excel doc outside of VBA but it just re formats to all the extra numbers when I run the code.
I've tried Me.TextBox2.Value = Format(Me.TextBox1.Value, "0.00") and a few other things in the code but nothing I try seems to be working.
Thanks for any guidance!
 
We also have a vlookup in the worksheet itself which is: =(VLOOKUP(A192,'\\192.168.28.60\pasdas\Reports\[2020PasDasCitectDataCollectionDaily.xlsm]B1Data'!$A$1:$IV$371,251))

I also want to add that I did not create this file or do very much of the coding for it, but as an intern I'm tasked with figuring out how to update it. I appreciate your help!!
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
None of that code is formatting a textbox.
 
Upvote 0
I wasn't sure you could use code to format a textbox. How would I format a text box to allow only 2 decimal places?
 
Upvote 0
When I tried that it didn't seem to work. Is there a spot in the code that you think it would work better or does it not matter about placement?
 
Upvote 0
Did you change the Textbox names to match your textboxes?
Please post the code that you are using, including how you populate the textbox initially.
 
Upvote 0

Forum statistics

Threads
1,223,626
Messages
6,173,402
Members
452,514
Latest member
cjkelly15

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