#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default ComboBox

Hi,

Can someone help me with populating a ComboBox with say
Text Line 1
Text Line 2
Text Line 3
Than after the user chooses one say 'Text Line 2' have it show his pick in
the Combobox. User would than have to click an 'OK' button to dislplay it in
say in ("D4"). I would want the ability to able to add more 'Text Lines' to
the code myself.

If this is asking to much could someone direct me to a site that might have
such a routine or to someone I could pay for his or her services.
Thanks,
James


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default ComboBox

Link the RowSource (if a form) property of the combobox to the range of data
on the worksheet, and set the Controlsource property to D4 to get the value
stored there.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"James Montgomery" wrote in message
...
Hi,

Can someone help me with populating a ComboBox with say
Text Line 1
Text Line 2
Text Line 3
Than after the user chooses one say 'Text Line 2' have it show his pick

in
the Combobox. User would than have to click an 'OK' button to dislplay it

in
say in ("D4"). I would want the ability to able to add more 'Text Lines'

to
the code myself.

If this is asking to much could someone direct me to a site that might

have
such a routine or to someone I could pay for his or her services.
Thanks,
James




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default ComboBox

Hi Bob

The sourse lines of text are not from a row but just lines of text I have
created for the CombeBox. But anyway not sure how to link all this and make
it work
Thanks

"Bob Phillips" wrote in message
...
Link the RowSource (if a form) property of the combobox to the range of

data
on the worksheet, and set the Controlsource property to D4 to get the

value
stored there.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"James Montgomery" wrote in message
...
Hi,

Can someone help me with populating a ComboBox with say
Text Line 1
Text Line 2
Text Line 3
Than after the user chooses one say 'Text Line 2' have it show his pick

in
the Combobox. User would than have to click an 'OK' button to dislplay

it
in
say in ("D4"). I would want the ability to able to add more 'Text Lines'

to
the code myself.

If this is asking to much could someone direct me to a site that might

have
such a routine or to someone I could pay for his or her services.
Thanks,
James






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default ComboBox

and yes I'm using a user form

"Bob Phillips" wrote in message
...
Link the RowSource (if a form) property of the combobox to the range of

data
on the worksheet, and set the Controlsource property to D4 to get the

value
stored there.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"James Montgomery" wrote in message
...
Hi,

Can someone help me with populating a ComboBox with say
Text Line 1
Text Line 2
Text Line 3
Than after the user chooses one say 'Text Line 2' have it show his pick

in
the Combobox. User would than have to click an 'OK' button to dislplay

it
in
say in ("D4"). I would want the ability to able to add more 'Text Lines'

to
the code myself.

If this is asking to much could someone direct me to a site that might

have
such a routine or to someone I could pay for his or her services.
Thanks,
James






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default ComboBox

Okay, so use

Private Sub Userform_Activate()

With Me.ComboBox1
.AddItem "Text1"
.AddItem "Text2"
'.. etc

.ControlSource = Range("D4").Address(external:=True)

End With

End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"James Montgomery" wrote in message
...
Hi Bob

The sourse lines of text are not from a row but just lines of text I have
created for the CombeBox. But anyway not sure how to link all this and

make
it work
Thanks

"Bob Phillips" wrote in message
...
Link the RowSource (if a form) property of the combobox to the range of

data
on the worksheet, and set the Controlsource property to D4 to get the

value
stored there.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"James Montgomery" wrote in message
...
Hi,

Can someone help me with populating a ComboBox with say
Text Line 1
Text Line 2
Text Line 3
Than after the user chooses one say 'Text Line 2' have it show his

pick
in
the Combobox. User would than have to click an 'OK' button to dislplay

it
in
say in ("D4"). I would want the ability to able to add more 'Text

Lines'
to
the code myself.

If this is asking to much could someone direct me to a site that might

have
such a routine or to someone I could pay for his or her services.
Thanks,
James










  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default ComboBox


Thanks Bob
I got it all working with the OK button
Thanks again
James

"Bob Phillips" wrote in message
...
Okay, so use

Private Sub Userform_Activate()

With Me.ComboBox1
.AddItem "Text1"
.AddItem "Text2"
'.. etc

.ControlSource = Range("D4").Address(external:=True)

End With

End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"James Montgomery" wrote in message
...
Hi Bob

The sourse lines of text are not from a row but just lines of text I

have
created for the CombeBox. But anyway not sure how to link all this and

make
it work
Thanks

"Bob Phillips" wrote in message
...
Link the RowSource (if a form) property of the combobox to the range

of
data
on the worksheet, and set the Controlsource property to D4 to get the

value
stored there.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"James Montgomery" wrote in message
...
Hi,

Can someone help me with populating a ComboBox with say
Text Line 1
Text Line 2
Text Line 3
Than after the user chooses one say 'Text Line 2' have it show his

pick
in
the Combobox. User would than have to click an 'OK' button to

dislplay
it
in
say in ("D4"). I would want the ability to able to add more 'Text

Lines'
to
the code myself.

If this is asking to much could someone direct me to a site that

might
have
such a routine or to someone I could pay for his or her services.
Thanks,
James










  #7   Report Post  
Posted to microsoft.public.excel.programming
MVM MVM is offline
external usenet poster
 
Posts: 53
Default ComboBox

I am having a combobox on a worksheet. I like to fill it in the
worksheet_open() function. In VBA how do i get these methods? - additem,
dataitem, list etc for combobox.

I declared a worksheet wb code in thisworkbook
--------------------
Option Explicit
Public DeptLocRange As Range, AcctRange As Range
Public ws As Worksheet
Private Sub Workbook_Open()
Dim r As Integer
Set ws = Me.Worksheets("Expenses")
With ws
Set DeptLocRange = .Range(.Cells(79, 3), .Cells(86, 6))
Set AcctRange = .Range(.Cells(91, 3), .Cells(92, 16))
r = 2
DeptLocRange.Select
' Worksheets("Expenses").cmbLocation.AddItem ("<select Loc")
' While Not IsNull(DeptLocRange(r, 1))
' .cmbLocation.AddItem = DeptLocRange(r, 1)
' Wend
' .cmbLocation.ListIndex = 0
' .cmbDepartment.ListIndex = 0
End With
Worksheets("Expenses").cmbLocation.ListIndex = 0
Worksheets("Expenses").cmbDepartment.ListIndex = 0
End Sub

--------------------
commented lines are not working. wb.cmbLocation.listindex won't work. but
the last two lines works. Any help is greatly appreciated.

Thanks
MVMurthy
********************
"Bob Phillips" wrote:

Okay, so use

Private Sub Userform_Activate()

With Me.ComboBox1
.AddItem "Text1"
.AddItem "Text2"
'.. etc

.ControlSource = Range("D4").Address(external:=True)

End With

End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"James Montgomery" wrote in message
...
Hi Bob

The sourse lines of text are not from a row but just lines of text I have
created for the CombeBox. But anyway not sure how to link all this and

make
it work
Thanks

"Bob Phillips" wrote in message
...
Link the RowSource (if a form) property of the combobox to the range of

data
on the worksheet, and set the Controlsource property to D4 to get the

value
stored there.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"James Montgomery" wrote in message
...
Hi,

Can someone help me with populating a ComboBox with say
Text Line 1
Text Line 2
Text Line 3
Than after the user chooses one say 'Text Line 2' have it show his

pick
in
the Combobox. User would than have to click an 'OK' button to dislplay

it
in
say in ("D4"). I would want the ability to able to add more 'Text

Lines'
to
the code myself.

If this is asking to much could someone direct me to a site that might
have
such a routine or to someone I could pay for his or her services.
Thanks,
James









  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default ComboBox

Are you sure it's the commented lines that's causing the trouble.

If you get rid of deptLocRange.select, will it work?

And if you change isNull() to isEmpty() does that help?

If neither of these fixes your problem, maybe you can post some more details of
what happens when you step through the code.



MVM wrote:

I am having a combobox on a worksheet. I like to fill it in the
worksheet_open() function. In VBA how do i get these methods? - additem,
dataitem, list etc for combobox.

I declared a worksheet wb code in thisworkbook
--------------------
Option Explicit
Public DeptLocRange As Range, AcctRange As Range
Public ws As Worksheet
Private Sub Workbook_Open()
Dim r As Integer
Set ws = Me.Worksheets("Expenses")
With ws
Set DeptLocRange = .Range(.Cells(79, 3), .Cells(86, 6))
Set AcctRange = .Range(.Cells(91, 3), .Cells(92, 16))
r = 2
DeptLocRange.Select
' Worksheets("Expenses").cmbLocation.AddItem ("<select Loc")
' While Not IsNull(DeptLocRange(r, 1))
' .cmbLocation.AddItem = DeptLocRange(r, 1)
' Wend
' .cmbLocation.ListIndex = 0
' .cmbDepartment.ListIndex = 0
End With
Worksheets("Expenses").cmbLocation.ListIndex = 0
Worksheets("Expenses").cmbDepartment.ListIndex = 0
End Sub

--------------------
commented lines are not working. wb.cmbLocation.listindex won't work. but
the last two lines works. Any help is greatly appreciated.

Thanks
MVMurthy
********************
"Bob Phillips" wrote:

Okay, so use

Private Sub Userform_Activate()

With Me.ComboBox1
.AddItem "Text1"
.AddItem "Text2"
'.. etc

.ControlSource = Range("D4").Address(external:=True)

End With

End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"James Montgomery" wrote in message
...
Hi Bob

The sourse lines of text are not from a row but just lines of text I have
created for the CombeBox. But anyway not sure how to link all this and

make
it work
Thanks

"Bob Phillips" wrote in message
...
Link the RowSource (if a form) property of the combobox to the range of
data
on the worksheet, and set the Controlsource property to D4 to get the
value
stored there.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"James Montgomery" wrote in message
...
Hi,

Can someone help me with populating a ComboBox with say
Text Line 1
Text Line 2
Text Line 3
Than after the user chooses one say 'Text Line 2' have it show his

pick
in
the Combobox. User would than have to click an 'OK' button to dislplay
it
in
say in ("D4"). I would want the ability to able to add more 'Text

Lines'
to
the code myself.

If this is asking to much could someone direct me to a site that might
have
such a routine or to someone I could pay for his or her services.
Thanks,
James










--

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
fill combobox depending on selection from another combobox Adam Francis Excel Discussion (Misc queries) 2 July 24th 08 07:39 PM
How Do I Load A ComboBox RowSource From The Results Of Another ComboBox Minitman[_4_] Excel Programming 3 October 26th 04 07:58 PM
Populating combobox from another combobox David Goodall Excel Programming 1 September 12th 04 03:42 PM
ComboBox Alex Mackenzie Excel Programming 0 July 2nd 04 08:48 PM
ComboBox No Name Excel Programming 2 June 10th 04 05:15 PM


All times are GMT +1. The time now is 11:40 AM.

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"