Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to display a negative 'number' 3

Status
Not open for further replies.

PeteG

Programmer
Feb 23, 2001
144
GB
Hi,
I have a process that ends with a set of numbers being copied from the screen of one application and pasted into Excel. All works fine; the only 'not so nice' is that negative values appear in the other app as the number followed by a negative sign, eg 5-. When pasted into Excel, these are interpreted as text and therefore not formatted correctly.

I'd like to have some way to automatically make these get displayed as proper negative numbers but I can't think of a simple way to do it. I can iterate through the range and wherever I find a 'number' like this, take off the '-' at the end and put one on the beginning of the number - then it would become a number and would display appropriately...but I keep thinking there must be an easier way to do it??
Thanks
 
I don't think there's another way to do it in Excel. Is there anything you can do in the source application?

What about the routine that copies the numbers from the other application? Can you interrogate the data during the copy?

_________________
Bob Rashkin
 
I don't think so. The 'process' is a 'screen-scraping' exercise that just copies characters from specfifc co-ords. I don't think I can interact with it at any more detailed level unfortunately.
Thanks for the reply though.
 




I screen scrape, using Attachmate. It is possible to manipulate the data before writing it.

What scraper software are you using?

Skip,

[glasses]Just traded in my old subtlety...
for a brand NUANCE![tongue]
 
Yes, it is Attachmate as well! However, I wrote a quick test to carry out on each cell which suits my purpose fine.

Code:
If Right(rge.Value, 1) = "-" Then
    rge.Value = "-" & Left(rge.Value, Len(rge.Value) - 1)
End If

Thanks
 



Code:
If Right(rge.Value, 1) = "-" Then
    rge.Value = Left(rge.Value, Len(rge.Value) - 1) [b]* (-1)[/b]
End If


Skip,

[glasses]Just traded in my old subtlety...
for a brand NUANCE![tongue]
 
Even simpler:
Code:
If Right(rge.Value, 1) = "-" Then
    rge.Value = -Val(rge.Value)
End If

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Excellent! Thanks to you both - and I'll go with the one that is the least typing!
 





PHV,

Good tip! ==> *

Skip,

[glasses]Just traded in my old subtlety...
for a brand NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top