Hello, Okay, the following did not quite work.
Go to menu insert/name/define and type name "Fans" refers to:
=OFFSET(Quote!$G$31,COUNTA(Quote!$G:$G),0,)
(I assume yor worksheet is named Sheet1, no other cells filled
in column G, except G30 which is a column header, if not - you need to
adjust the formula).
In combo box properties:
Row Source N90:O140
ColumnCount 2
Control Source Fans.
In the Control Source it comes back with an error message, Invalid Property
Value.
So I set the control source as G31
' This code crashes possibly due to the above
Private Sub ComboFans_Change()
Range("go").Offset(-1, 1) = ComboFans.List(ComboFans.ListIndex, 1)
End Sub
In Cells G30 and H30, there are complicated Index and match formulas which
are working for another ComboBox on the
Quote worksheet, so these cannot be overwritten.
On the Quote worksheet their is a button, which when clicked pops up a
userform, which has Checkbox items on it.
When any of these items is chosen, it places text in the first available
cell from G31 to G43.
In cells H31 to H43, index and match formulas match a product with the text,
that has been placed by the checkbox items.
The combofan box, lists all of a range of fans from N90:O140, (See row
source above)
when a fan is chosen from this Combo, the code needs to check the first
availble cell from G31to G43, then place
the first part of the chosen fan, (which will be somewhere From N90:N140) in
this cell.
As an example. If In cell N100, I have the text"A50" and in cell O100 I have
"Gold Ceilng fan". (Ignore Quotation marks)
When the combobox chooses this one, it places A50, in the first available
Cell from G31 to G43.
Then if I choose any more items from the various checkboxes, these will then
be placed in the first availble cell within the same range of G31:G43.
The above code as mentioned by MK is very close to working, and is the only
answer that I have tried, as I do not know enough about VB, to understand
the other answers, and has to how I can relate them to my worksheet.
Although I must thank all who answered, as it is not allways easy to
undestand exactly what a person is trying to achieve
when all you have to go by is a text post.
anymore help would be very much appreciated.
Thanking you all in advance
Greg Simms
Greg Simms said:
Thank you, I will now try out all the various pieces of help that I have
recieved.
Thanks again
Greg Simms
Dave Peterson said:
When those kinds of comboboxes are placed on the worksheet, they have those
properties.
When they're on a userform, they're called something different:
listfillrange becomes RowSource
linkedcell becomes controlsource
columncount becomes columncount <bg>
I created a form with a combobox and a commandbutton on it and and used this
code behind the userform:
Option Explicit
Private Sub ComboBox1_Change()
If Me.ComboBox1.ListIndex < -1 Then
Me.CommandButton1.Enabled = False
Else
Me.CommandButton1.Enabled = True
End If
End Sub
Private Sub CommandButton1_Click()
Dim destCell As Range
If Me.ComboBox1.ListIndex < 0 Then
Exit Sub
End If
With Worksheets("sheet1")
Set destCell = .Cells(.Rows.Count, "G").End(xlUp).Offset(1, 0)
If destCell.Row < 31 Then
Set destCell = .Range("G31")
End If
End With
With Me.ComboBox1
destCell.Value = .List(.ListIndex, 0)
destCell.Offset(0, 1).Value = .List(.ListIndex, 1)
End With
Unload Me
End Sub
Private Sub UserForm_Initialize()
With Me.ComboBox1
.ColumnCount = 2
.RowSource _
= Worksheets("sheet1").Range("N90:O140").Address(external:=True)
.Style = fmStyleDropDownList
End With
Me.CommandButton1.Enabled = False
End Sub
I did assume that all this stuff was happening to Sheet1.
cells