ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel & C# NullReference Error when trying to set Range.Value2 (https://www.excelbanter.com/excel-programming/369183-excel-c-nullreference-error-when-trying-set-range-value2.html)

Chuck

Excel & C# NullReference Error when trying to set Range.Value2
 
When trying to assign a string to the Value2 property of a Range:

WorksheetA.get_Range("A1",Type.Missing).Value2=cur Value.Trim();

I'm getting this error message:
Object reference not set to an instance of an object.

Any suggestions?

Chuck

Excel & C# NullReference Error when trying to set Range.Value2
 
Also, the Range is not null, it is the Value2 object that is null. The
mystery is how to ensure that the Value2 object is not null.

"Chuck" wrote:

When trying to assign a string to the Value2 property of a Range:

WorksheetA.get_Range("A1",Type.Missing).Value2=cur Value.Trim();

I'm getting this error message:
Object reference not set to an instance of an object.

Any suggestions?



All times are GMT +1. The time now is 09:20 PM.

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