ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cells format (https://www.excelbanter.com/excel-programming/305313-cells-format.html)

fragher75

Cells format
 
Hi.

I have a problem. When I import a .txt file create by an accountin
software, where there are negative numbers value in this format (fo
example 150-), after the importation those numbers have a text forma
and I can't sum them with the other numbers. I have a custom forma
(#.##0;#.##0-) but I can't apply it after the importation.

Can you help me

--
Message posted from http://www.ExcelForum.com


Frank Kabel

Cells format
 
Hi
try using 'Data - Text to columns' to convert the negative
numbers to rela values

-----Original Message-----
Hi.

I have a problem. When I import a .txt file create by an

accounting
software, where there are negative numbers value in this

format (for
example 150-), after the importation those numbers have a

text format
and I can't sum them with the other numbers. I have a

custom format
(#.##0;#.##0-) but I can't apply it after the importation.

Can you help me?


---
Message posted from http://www.ExcelForum.com/

.


Tom Ogilvy

Cells format
 
In most cases, a format does not affect what is stored in the cell. Excel
sees 150- as a string. Therefore, you number format has no effect. You can
use a macro to fix them

Select the cells and run a macro like this

Sub PostfixNegative()
Dim rng as Range, cell as Range
if selection.count 1 then
On Error Resume Next
set rng = selection.specialCells(xlConstants,xlTextValues)
On Error goto 0
else
set rng = selection
End if
if not rng is nothing then
for each cell in rng
if Right(trim(cell.value),1) = "-" then
Cell.Value = cdbl(cell.Value)
end if
Next
End if
End Sub

--
Regards,
Tom Ogilvy

"fragher75 " wrote in message
...
Hi.

I have a problem. When I import a .txt file create by an accounting
software, where there are negative numbers value in this format (for
example 150-), after the importation those numbers have a text format
and I can't sum them with the other numbers. I have a custom format
(#.##0;#.##0-) but I can't apply it after the importation.

Can you help me?


---
Message posted from http://www.ExcelForum.com/




Tom Ogilvy

Cells format
 
Doesn't work in Excel 2000 or Excel 97 at least. (as far as reevaluating
the cells. If you meant to separate the number from the negative sign, that
would be different).

--
Regards,
Tom Ogilvy

"Frank Kabel" wrote in message
...
Hi
try using 'Data - Text to columns' to convert the negative
numbers to rela values

-----Original Message-----
Hi.

I have a problem. When I import a .txt file create by an

accounting
software, where there are negative numbers value in this

format (for
example 150-), after the importation those numbers have a

text format
and I can't sum them with the other numbers. I have a

custom format
(#.##0;#.##0-) but I can't apply it after the importation.

Can you help me?


---
Message posted from http://www.ExcelForum.com/

.





All times are GMT +1. The time now is 02:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com