ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ComboBox (https://www.excelbanter.com/excel-programming/317443-combobox.html)

James Montgomery

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



Bob Phillips[_6_]

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





James Montgomery

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







James Montgomery

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







Bob Phillips[_6_]

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









James Montgomery

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











MVM

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










Dave Peterson[_5_]

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


All times are GMT +1. The time now is 12:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com