This piece of code can't change formattings for MS Excel range (cell/cells), because
myselection
variable has been declared and never initiated.
Dim myselection as Excel.Range
myselection.NumberFormat = "[$-2000000]#,#;[Red](#,##0)"
All you have to do is to initiate that variable, for example:
Dim myselection as Excel.Range = CType(ExcelApp.Worksheets("Sheet1").Range("A17"), Excel.Range)
myselection.NumberFormat = "[$-2000000]#,#;[Red](#,##0)"
For further details, please see:
Excel Object Model Overview[
^]
Understanding the Excel Object Model from a .NET Developer’s Perspective[
^]
Working with Ranges[
^]
Range.NumberFormat Property (Excel)[
^]
Good luck!