简体   繁体   中英

Heading Bug Excel VBA

I need your help regarding to a bug a have in my excel file. We use Jama tool and we have imported some items from there like Heading, ID, Name etc. The thing is that when the heading is for example 7.9 the excel generates 7,9. I checked the sequence/heading how it is stored in Jama and everything is fine. ( The heading there is as it should be, 7.9). The only solution that came into my mind is to use .DecimalSeparatior. It turns the comma into a point but the heading is stored in the right part of the cell as it is not considered as a heading (I guess, sorry I am totally new with vba). I have other headings also in the format 3.14.5.8

Please help! Here's some code regarding to the heading/sequence. Should I add something here? If yes, what?

sPastCellContant = rCell.Offset(0, cHeading - 1)
rCell.Offset(0, cHeading - 1) = oResponseDataLocation("sequence")
If rCell.Offset(0, cHeading - 1) <> sPastCellContant Then
    rCell.Offset(0, cHeading - 1).Interior.ColorIndex = ChangedColour
End If

If the 7.9 is not a floating point number for you but a numbering, then you should format the cell to text format before you are putting that numbering as content into the cell.

Example:

...
rCell.Offset(0, cHeading - 1).NumberFormat = "@"
rCell.Offset(0, cHeading - 1).Value = oResponseDataLocation("sequence")
...

Now, if oResponseDataLocation("sequence") is "7.9", the 7.9 will be text and not numeric content.

Background is that even if Excel uses locale settings where comma is the decimal separator, VBA will always using en_US locale having dot as decimal separator.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM