View Single Post
 
Old 03-07-2018, 04:48 AM
ArviLaanemets ArviLaanemets is offline Windows 8 Office 2016
Expert
 
Join Date: May 2017
Posts: 873
ArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud of
Default Excel VBA interprets numeric values from worksheet formatted as General in several ways

We get from clients purchase forecasts info as text/Excel/HTML/etc. files.

I have created for client managers Excel applications, which open client file, read in data from there, make some calculations, and write results as table in certain format into Excel or into text file. The result table is then read into our ERP system.

Currently I have problem with xls-type Excel file from client.
When I open the file with Excel, I get the message "The file format and extension of 'ClientFileName.XLS' don't match. The file could be corrupted or unsafe. Unless you trust its source, don't open it. Do you want to open it anyway". Obviously the client had original file p.e. in xlsx-format, and simply renamed extension instead of opening the file and using Save As to convert it. Anyway I haven't control over it.

When I click Yes, the file opens OK. All cells on worksheet are formatted as General. As most entries are integer values, they are displayed as numbers (aligned to right). The only column having entries with decimals is also OK in my computer with comma as decimal delimiter, and in colleges computer with point as decimal delimiter.

When the VBA opens the same file, it is a mess!
Some columns remain OK. 1 remains 1, 0 remains 0, etc;
In other columns 1 - 3 decimal zeros are added to integers, and they are interpreted as texts (in my computer in one column 100 is shown as 100,0, in other column 0 is displayed as 0,000 - all aligned to left), etc.;
The worst columns multiply all values with 1000, except 0's. P.e. 1500 is now displayed 1 500 000 in my computer (I have space as thousands delimiter), and 1,500,000 in colleges computer (she has US settings). And 0 is replaced in my computer as text 0,000 (aligned to left).

Ha someone a clue what is going on?
Reply With Quote