combox box

S

Steve

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.
 
S

Sam Wilson

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
 
S

Steve

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top