vba listbox question

D

Devitt

How do i add stuff to a second column in a vba listbox.. i feel reall
stupid but i've tried endlessly and searched the internet with n
joy...

Also how can i use info from a particular column..

eg.

Surname/name are 2 column headings (assuming i can get stuff in the 2n
colum)

i wanna take data from 'surname' without takin the 'name' data wit
it...

I know this is really simple basic stuff so can someone put me out o
my misery
 
D

Devitt

Could someone please help me? This is really annoying and i can't get o
with my work until i know how to do this..
 
D

Devitt

Wow didnt realise it was that hard to use multiple columns on
listbox... no wonder i couldn't do it..
Why does it have a 'columncount' property if its stupidly hard to pu
stuff in anyother column than the 1st one.....
Cause if a forum full of experts cant help me then im pretty muc
f**ked... can someone atleast tell me if its possible
 
D

Devitt

[column1] [column2]
-----Z----------X---------





Above is a listbox.... i wanna put data where the 'x' is.. but it keep
going where the 'z' is...
is that explained beta?
loads of people viewing but not helping... :
 
D

Devitt

Can someone please help me? It sounds really simple, but i cant get it
to work so its getting really annoying...
 
M

Mauro Gamberini

Your table A1:B10

Dim x As Integer
Dim y As Integer

x = Application.WorksheetFunction.CountA(Sheet1.Range("A1:A10"))

For y = 1 To x
ComboBox1.AddItem (Sheet1.Range("A" & y).Value & " " &
Sheet1.Range("B" & y).Value)
Next
 
H

Harald Staff

Devitt > said:
[column1] [column2]
-----Z----------X---------
Above is a listbox.... i wanna put data where the 'x' is.. but it keeps
going where the 'z' is...
is that explained beta?
loads of people viewing but not helping... :(

Start behaving and I may reconsider.

Best wishes Harald
 
D

Devitt

Ok that didn't work just put all the stuff in coloum 1 of the listbox..
but thank you for replying!!! i think ill just give up and smash th
absolute **** out of the pc monitor..

hmm.. ill try explain again cause i aint too good at it

you know how you can set the amount of columns for a listbox?
Well all i wanna do is set a listbox to have 2 columns and put the wor
'rabbit' in the 2nd column. When i try myself, the word 'rabbit' appear
in the 1st column everytime
 
D

Devitt

Harald said:
Start behaving and I may reconsider.

Best wishes Harald [/B]

If you'd been waiting 2+ hours for help on something you know is ver
simple and that is restricting you from finishing your project, you'
be pissed off too..
 
H

Harald Staff

Devitt > said:
Harald said:
Start behaving and I may reconsider.

Best wishes Harald [/B]

If you'd been waiting 2+ hours for help on something you know is very
simple and that is restricting you from finishing your project, you'd
be pissed off too...

This is a worldwide internet community where users from all timezones of the
globe assist other users, voluntarily and for free. I get pissed off when
people like you are impatient, rude and treats this as some kind of paid AND
lousy service. Do your own homework, brat.

Best wishes Harald
 
D

Dave Peterson

Maybe:

Option Explicit
Private Sub ListBox1_Click()
MsgBox Me.ListBox1.Value
End Sub
Private Sub UserForm_Initialize()
With Me.ListBox1
.ColumnHeads = True
.ColumnCount = 2
.BoundColumn = 2
.RowSource = Worksheets("sheet1") _
.Range("a2:b100").Address(external:=True)
End With
End Sub

(although I agree with Harald and Mauro.)
 
Top