Decimal formatting for output to text file

jcrook

New Member
Joined
Jun 12, 2020
Messages
15
Office Version
  1. 2016
Platform
  1. Windows
Good Afternoon,
I am taking input from excel data and manipulating the values to generate CNC program code for metal cutting CNC machines. I'm sure there are many things wrong with this macro. But, I need to output a numbers to a ".txt" file that has at least a decimal point. The values that are currently "doubles" are output with a decimal. The values that are entered into the spreadsheet as decimals, ex: 1.0 or 3.0, endup as integers upon output to the text file. This is a no-no for a cnc control because a coordinate like X4 is actually read as X0.0004 because the industry standard is 4 places to the right of the decimal point if none is input. Where X1. = X1., again X3 = X0.0003. This is tenths of thousands in inch.
I've a screen shot of the spreadsheet, the text output, and some screen shots of the macro code where I'm printing to the text file. I'm not using "Write" because it includes the "" marks, these are not understood by the control.
I need to output everything as a decimal number(double). I would like all values to have at least 1 zero to the right of the dec pt, X1 = X1.0.
Thanks in Advance,
Jay.
 

Attachments

  • Rect Pckt Screen Shot.PNG
    Rect Pckt Screen Shot.PNG
    83.6 KB · Views: 33
  • cnc text file.PNG
    cnc text file.PNG
    29.7 KB · Views: 34
  • rect macro code1.PNG
    rect macro code1.PNG
    44.3 KB · Views: 29
  • rect macro code2.PNG
    rect macro code2.PNG
    49.2 KB · Views: 25
delighted to have helped. Another thought would be to do all the calculations in Excel rather than VBA - you would be able to see all the results before printing and could structure a page with all the output cells in the right order for checking before simply saving that region as a text file. Possibly no need for VBA at all.

All the best.
 
Upvote 0

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Hi Peter,
Thanks Again for our help.
I have another worksheet in the same workbook similar to your last reply.
I'll look at outputting that region to a text file.

Thanks Again,
Jay.
 
Upvote 0

Forum statistics

Threads
1,215,035
Messages
6,122,785
Members
449,095
Latest member
m_smith_solihull

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