ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   combox box (https://www.excelbanter.com/excel-programming/429387-combox-box.html)

Steve

combox box
 
Howdie all.
I've made a user form, and set it up with some combo boxes.
Presently, my equations are asking for the input for 4 comboboxes. If a
combobox is empty, it still inputs a blank value.

I'd like to set it up so that if a value is not chosen for a combo box, it
leaves that blank value out of the final input.

Presently my equation reads:

ActiveCell.value = Me.ComboBox1.value & Chr(10) & Me.ComboBox2.value &
Chr(10) & Me.ComboBox3.value & Chr(10) & Me.ComboBox4.value

For example, what I've got is combobox1 has a value, and then combobox2 and
3 are blank, then combobox4 has a value.
Instead of placing two blanks in the input, I'd like it to only have the
values from 1 and 4 input.
I.e.,
Instead of
A


D
I'd like
A
D

How would I accomplish that?
Thank you in advance for your helps.
Best.

Sam Wilson

combox box
 
dim str1 as string
if me.combobox1.value = "" then str1 = me.combobox1.value & chr(10)
if me.combobox2.value = "" then str1 = str1 & me.combobox2.value & chr(10)
if me.combobox3.value = "" then str1 = str1 & me.combobox3.value & chr(10)
if me.combobox4.value = "" then str1 = str1 & me.combobox4.value & chr(10)
str1 = left(str1,len(str1)-1)

ActiveCell.value = str1


"Steve" wrote:

Howdie all.
I've made a user form, and set it up with some combo boxes.
Presently, my equations are asking for the input for 4 comboboxes. If a
combobox is empty, it still inputs a blank value.

I'd like to set it up so that if a value is not chosen for a combo box, it
leaves that blank value out of the final input.

Presently my equation reads:

ActiveCell.value = Me.ComboBox1.value & Chr(10) & Me.ComboBox2.value &
Chr(10) & Me.ComboBox3.value & Chr(10) & Me.ComboBox4.value

For example, what I've got is combobox1 has a value, and then combobox2 and
3 are blank, then combobox4 has a value.
Instead of placing two blanks in the input, I'd like it to only have the
values from 1 and 4 input.
I.e.,
Instead of
A


D
I'd like
A
D

How would I accomplish that?
Thank you in advance for your helps.
Best.


Steve

combox box
 
Hi Sam,
Thank you for the response.
For a reason that I'm not quite clear on this leaves the affected cells
blank, even if I choose specific values.
In fact the only two cells receiving any input are one's not affected by
this code.
I also removed the left component thinkingthat might be the issue, and I get
the same response.

"Sam Wilson" wrote:

dim str1 as string
if me.combobox1.value = "" then str1 = me.combobox1.value & chr(10)
if me.combobox2.value = "" then str1 = str1 & me.combobox2.value & chr(10)
if me.combobox3.value = "" then str1 = str1 & me.combobox3.value & chr(10)
if me.combobox4.value = "" then str1 = str1 & me.combobox4.value & chr(10)
str1 = left(str1,len(str1)-1)

ActiveCell.value = str1


"Steve" wrote:

Howdie all.
I've made a user form, and set it up with some combo boxes.
Presently, my equations are asking for the input for 4 comboboxes. If a
combobox is empty, it still inputs a blank value.

I'd like to set it up so that if a value is not chosen for a combo box, it
leaves that blank value out of the final input.

Presently my equation reads:

ActiveCell.value = Me.ComboBox1.value & Chr(10) & Me.ComboBox2.value &
Chr(10) & Me.ComboBox3.value & Chr(10) & Me.ComboBox4.value

For example, what I've got is combobox1 has a value, and then combobox2 and
3 are blank, then combobox4 has a value.
Instead of placing two blanks in the input, I'd like it to only have the
values from 1 and 4 input.
I.e.,
Instead of
A


D
I'd like
A
D

How would I accomplish that?
Thank you in advance for your helps.
Best.



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

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