Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Listboxes Without User Form

Hello people,

I have one combobox on my sheet and I am trying to put a listbox on the same
sheet.
so when i click on Add To List button it should add the selected value from
combobox to the listbox.
but i m not able to insert a listbox.
can anyone please help me with this.


This is the code i m using to insert a listbox on my sheet.
and i m getting Type Mismatch error

Sub TEST()
Dim oOLE As OLEObject
Dim lstCustomers As ListBox

Set oOLE = ActiveSheet.OLEObjects.Add(ClassType:="Forms.ListB ox.1",
Left:=537, Top:=89, Width:=120, Height:=15)

Set lstCustomers = oOLE.Object
End Sub

hope to hear something on this.
Vipul Agheda
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Listboxes Without User Form

Why are you trying to add it in code, why not just add it in design?

--
__________________________________
HTH

Bob

"Vipul" wrote in message
...
Hello people,

I have one combobox on my sheet and I am trying to put a listbox on the
same
sheet.
so when i click on Add To List button it should add the selected value
from
combobox to the listbox.
but i m not able to insert a listbox.
can anyone please help me with this.


This is the code i m using to insert a listbox on my sheet.
and i m getting Type Mismatch error

Sub TEST()
Dim oOLE As OLEObject
Dim lstCustomers As ListBox

Set oOLE = ActiveSheet.OLEObjects.Add(ClassType:="Forms.ListB ox.1",
Left:=537, Top:=89, Width:=120, Height:=15)

Set lstCustomers = oOLE.Object
End Sub

hope to hear something on this.
Vipul Agheda



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Listboxes Without User Form

hello bob,
thanks for your reply and question

actually i tried to add the listbox control in design mode, just straight
from the Forms toolbox to my sheet
but if i add it like that then i m not getting all those controls in the
coding.
i mean for example if i draw a listbox on my sheet, and name it as ListBox1,
then i am not getting that control in code.

thats why i m trying to add it using code.
if you know how can i use drawn controls in coding please please let me
know. thats what i wanted basically.

thanks again.
cheers mate


"Bob Phillips" wrote:

Why are you trying to add it in code, why not just add it in design?

--
__________________________________
HTH

Bob

"Vipul" wrote in message
...
Hello people,

I have one combobox on my sheet and I am trying to put a listbox on the
same
sheet.
so when i click on Add To List button it should add the selected value
from
combobox to the listbox.
but i m not able to insert a listbox.
can anyone please help me with this.


This is the code i m using to insert a listbox on my sheet.
and i m getting Type Mismatch error

Sub TEST()
Dim oOLE As OLEObject
Dim lstCustomers As ListBox

Set oOLE = ActiveSheet.OLEObjects.Add(ClassType:="Forms.ListB ox.1",
Left:=537, Top:=89, Width:=120, Height:=15)

Set lstCustomers = oOLE.Object
End Sub

hope to hear something on this.
Vipul Agheda




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Listboxes Without User Form

hey Dave
thanks a lot mate
it worked for me.
u know i m trying to get this for last 3 days.
and finally i got it from u
many thanks bro
cheers mate


"Dave Peterson" wrote:

Use:
Dim lstCustomers As msforms.ListBox

When you used:
Dim lstCustomers As ListBox

You were using the listbox from the Forms toolbar.

Vipul wrote:

Hello people,

I have one combobox on my sheet and I am trying to put a listbox on the same
sheet.
so when i click on Add To List button it should add the selected value from
combobox to the listbox.
but i m not able to insert a listbox.
can anyone please help me with this.

This is the code i m using to insert a listbox on my sheet.
and i m getting Type Mismatch error

Sub TEST()
Dim oOLE As OLEObject
Dim lstCustomers As ListBox

Set oOLE = ActiveSheet.OLEObjects.Add(ClassType:="Forms.ListB ox.1",
Left:=537, Top:=89, Width:=120, Height:=15)

Set lstCustomers = oOLE.Object
End Sub

hope to hear something on this.
Vipul Agheda


--

Dave Peterson

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Listboxes Without User Form

hi again dave,

now i got another problem
when i tried to add items in the list box i created, i m not able to
retrieve the added items but not able to see them.

here is the code:

Sub TEST1()
Dim oOLE As OLEObject
Dim lstCustomers As MSFORMS.ListBox
Set oOLE = ActiveSheet.OLEObjects.Add(ClassType:="Forms.ListB ox.1",
Left:=537, Top:=189, Width:=120, Height:=150)
Set lstCustomers = oOLE.Object
lstCustomers.AddItem "A"
lstCustomers.AddItem "b"
lstCustomers.AddItem "c"
lstCustomers.AddItem "d"
MsgBox lstCustomers.List(2)
End Sub



"Dave Peterson" wrote:

Use:
Dim lstCustomers As msforms.ListBox

When you used:
Dim lstCustomers As ListBox

You were using the listbox from the Forms toolbar.

Vipul wrote:

Hello people,

I have one combobox on my sheet and I am trying to put a listbox on the same
sheet.
so when i click on Add To List button it should add the selected value from
combobox to the listbox.
but i m not able to insert a listbox.
can anyone please help me with this.

This is the code i m using to insert a listbox on my sheet.
and i m getting Type Mismatch error

Sub TEST()
Dim oOLE As OLEObject
Dim lstCustomers As ListBox

Set oOLE = ActiveSheet.OLEObjects.Add(ClassType:="Forms.ListB ox.1",
Left:=537, Top:=89, Width:=120, Height:=15)

Set lstCustomers = oOLE.Object
End Sub

hope to hear something on this.
Vipul Agheda


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Listboxes Without User Form

I don't know why that happens.

Maybe you could use Bob's idea and place the listbox where you want it. Just
hide it or unhide it in your code.

Vipul wrote:

hi again dave,

now i got another problem
when i tried to add items in the list box i created, i m not able to
retrieve the added items but not able to see them.

here is the code:

Sub TEST1()
Dim oOLE As OLEObject
Dim lstCustomers As MSFORMS.ListBox
Set oOLE = ActiveSheet.OLEObjects.Add(ClassType:="Forms.ListB ox.1",
Left:=537, Top:=189, Width:=120, Height:=150)
Set lstCustomers = oOLE.Object
lstCustomers.AddItem "A"
lstCustomers.AddItem "b"
lstCustomers.AddItem "c"
lstCustomers.AddItem "d"
MsgBox lstCustomers.List(2)
End Sub

"Dave Peterson" wrote:

Use:
Dim lstCustomers As msforms.ListBox

When you used:
Dim lstCustomers As ListBox

You were using the listbox from the Forms toolbar.

Vipul wrote:

Hello people,

I have one combobox on my sheet and I am trying to put a listbox on the same
sheet.
so when i click on Add To List button it should add the selected value from
combobox to the listbox.
but i m not able to insert a listbox.
can anyone please help me with this.

This is the code i m using to insert a listbox on my sheet.
and i m getting Type Mismatch error

Sub TEST()
Dim oOLE As OLEObject
Dim lstCustomers As ListBox

Set oOLE = ActiveSheet.OLEObjects.Add(ClassType:="Forms.ListB ox.1",
Left:=537, Top:=89, Width:=120, Height:=15)

Set lstCustomers = oOLE.Object
End Sub

hope to hear something on this.
Vipul Agheda


--

Dave Peterson


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date field in user form & Loading a user form on opening workbook Balan Excel Programming 1 May 24th 08 03:40 PM
ref or tutorial for user forms, listboxes br549 Excel Programming 2 May 23rd 07 01:14 PM
Multi Listboxes with data dependent upon user choices SaturnGolfBoy Excel Programming 2 June 17th 06 01:50 AM
How to: User Form to assign a user defined range to a macro variab TrevTrav Excel Programming 1 March 22nd 05 07:57 PM
Form/Listboxes -- problems Stuart[_5_] Excel Programming 2 May 7th 04 07:23 AM


All times are GMT +1. The time now is 10:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"