VBA - accessing columns in a LISTBOX

  Heefie 14:49 14 Dec 2004

I'm sure that this will be very easy for somebody ...

I'm using VBA in EXCEL & I invoke a procedure when a cell changes. Within this procedure I have a Form with a Listbox that is populated from a NAME (Insert/Define/Name), details as follows :

='PROMOTR Codes'!$A$3:$B$100

The Listbox ColumnCount = 2 and the Column A data is in Column 1 of the Listbox & the Column B data is in Column 2 of the Listbox.

I can retrieve the Column 1 details easily enough, but don't know how to access the Column 2 data ... I am using the following, but the second command gives me an error :

Private Sub CmdOK_Click()

NewPromCode = TxtNewPromCode.Text
NewPromText = TxtNewPromCode.TextColumn(2)

Unload Me

End Sub

The Error Message is "Run-time error'-2147024809 (80070057) ... Could not get the Column property. Invalid argument," and if I GOOGLE on this message I only get 1 choice, and the link to that doesn't work !!!

Sorry for a huge question for what is probably a very short answer ... what am I doing wrong ?!?!?

  AccessMoron 13:51 16 Dec 2004

try TxtNewPromCode.TextColumn(1)

I think that the index is zero based

  Heefie 08:10 17 Dec 2004

... but don't have the result here !!!

IIRC it needed a double index,

NewPromText = TxtNewPromCode.Column(0, 1)

Cheers for at least trying though, I thought I was the only one that could see the post <s> !!!!

This thread is now locked and can not be replied to.

Elsewhere on IDG sites

Alienware 17 R4 2017 review

Interview: Camille Walala on her giant 3D installation inspired by childhood funfair visits

Best iPad buying guide 2017

Où regarder le British Open 2017 ?