this is the meat of the code:
Dim bound0 As Integer = array.GetUpperBound(0)
Dim bound1 As Integer = array.GetUpperBound(1)
For j As Integer = 1 To bound0
For x As Integer = 1 To bound1
If IsNumeric(array(j, x)) Then
Dim cell As String
cell = Chr(Asc(x) + 16) & Asc(Chr(j))
r = sheet.Range(cell)
r.NumberFormat = "#,##0.00"
array(j, x) = FormatNumber(array(j, x), 2)
array(j, x) = String.Format("{0:F}", array(j, x))
r = sheet.UsedRange
End If
Next
Next
End If
r = sheet.UsedRange
r.Value = array
my problem is, there are some alphanumeric values where i need to change the formatting of the number part of the cell example:
"Test Value: 123456.639"
that i need to change to:
"Test Value: 123,456.64"
the array(,) is declared this way:
Dim array(,) As Object = r.Value(XlRangeValueDataType.xlRangeValueDefault)
so what i thought is use something like this:
If array(j, x).ToString().Contains("Test Value: ") Then
'remove the Test Value: part and format the remaining
End If
but it gives me an "Object reference not set to an instance of an object." error
is there another way to solve my problem? thanks in advance

New Topic/Question
Reply




MultiQuote



|