VBA - accessing columns in a LISTBOX

  Heefie 14:49 14 Dec 04

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 04

try TxtNewPromCode.TextColumn(1)

I think that the index is zero based

  Heefie 08:10 17 Dec 04

... 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.

Intel Coffee Lake 8th-gen Core processors release date rumours

1995-2015: How technology has changed the world in 20 years

Framestore’s haunting post-WWII title sequence for new BBC series SS-GB

Best iPhone games 2017 | Best iPad games 2017: 162 fantastic iOS games that you need to play right…