Update2
Please see my answer to my question.
Update
So, I updated the code per @Eddy comment below, however I’m still getting an error on the myRange = Globals.Sheet…line.
Dim xlDown, i As Int32
Dim myRange As Excel.Range
myRange = Globals.Sheet1.Application.Transpose(
Globals.Sheet1.Range(
Globals.Sheet1.Range("A1"),
Globals.Sheet1.Range("A1").End(xlDown)).Value)
For i = 1 To myRange.Rows.Count
ListBox2.Items.Add(myRange.Cells(i, 1).Value)
Next i
ERROR says:
System.RuntimeType.ForwaredCallToInvokeMember(String memberName,
BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData&
msgData) at Microsoft.Office.Interop.Excel.Range.get_End(XlDirection
Direction)
Any Ideas?
Thanks again
———————————Orig Question————————————-
I have a VBA excel program that I’m converting to VB.net (using Visual Studio 2010) and I’m getting an error that I did not have in the old VBA version. The error occurs when I try to transpose the excel range to a listbox:
Property Items is readOnly
Within the With statment
Dim xlDown As Int32
With Globals.Sheet1
ListBox2.Items = Globals.Sheet1.Application.Transpose(
Globals.Sheet1.Range(
Globals.Sheet1.Range("A1"),
Globals.Sheet1.Range("A1").End(xlDown)).Value)
End With
I’m not sure what to do with this, maybe I’m not referencing the Globals.Sheet1 correctly?
Thank you
After doing some further research I figured out that I did not have to use the transpose method to assign the excel.range values to a listbox.
Thank you to those who responded.