Validate Range.Value2 on Excel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I need to read coordinates (x,y) from excel workbooks, where x coordinates are stored on column B and y on column C on worksheets. I need to read these values for further process in AutoCAD. My problem is that I can't find a way to properly validate these values from Excel. Both columns in the worksheet are number formatted with two decimal places. Initially, I thought well this is not a big deal I will check, (Range.Value2 != Null && Range.Value2 != string.Empty), to make sure the range is not blank. As you can see on the picture below the stored data contains 0.00 values and spaces. I only need to read the ranges (cells) which contain a valid values. I don't know how many rows contain values, so I need to go down on column B until all rows containing values have been read, say stop after reading 5 blank rows. My initial validation check generated errors like "Operator != cannot be applied to operands of type double and string" I also tried many combinations of checks and I have not been able to find one that I can use. Storing the range.value2 on a variable and checking after did not work because the number formatted cells return 0.0 which conflicts with the valid values. I have always copied data from AutoCAD to Excel, this is the first time I need to copy from Excel to AutoCAD. I hope some people here might have done this. Any suggestions will be greatly appreciated.
Please if anyone can suggest a way to do this properly, I will be greatly appreciated.