I'm using automation to export the item sales to Excel. It's working perfect but when the sales are negative, the exported value is formated as text in Excel.
(€ 1248- instead of -1248).
I tried to solve it with the following code:
Sheet.Range('B:M').NumberFormat := '#.##0;-#.##0';
But this is not working. Does anyone know the solution for this problem?
Best Regards,
Marcel Bierens
0
Comments
I am sorry not to respod to your initial question, but after what you have wrote you might be able to help me with a little automation problem ( I am in the beginnings...).
I am trying to export sales data to excel and I just don't find the function to tell excel with c/side code to swith to the next cell in a column once it has filled it with data. The Range command does not accept variables...
Help is really appreciated...
When you use this
xlsheet.Range('A' + FORMAT(i)).Value := 'some value';
you can use the i variable to move to the next row.
I have tried every possible order of these commands and FORMAT but it was the '+' that made all the difference...
Thank God for the Forums...
but, since I've just had the same problem and solved it (for my case at least) I thought: let's post the solution here.
Worksheet.Range('A'+FORMAT(Row)).Value := format(FieldName, 0, 0);
Worksheet.Range('A:A').NumberFormat := '#.##0;-#.##0';
what this does is make a string from the number in a standard format.
then we place that in the cell.
Afterwards we give the cell the format we want it to have in Excel.