ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,971
- Office Version
- 2007
- Platform
- Windows
Afternoon.
I use a small userform where comboboxes have values in a drop down that i then select from.
Sometimes when i click the drop down arrow the value i would like to use isnt there, as its new & never been used before.
So now i need to close the userform, add the values to the table where my values are stored & then start all over again.
Can we somehow allow a value to be added to the table if currently not present ?
The form opens up when i use the worksheet called X300 PRO 3 LIST
The values are stored on worksheet called DATABASE INFO
These comboboxes on the form relate to the column on the worksheet.
COMBOBOX 1 = Column A
COMBOBOX 2 = Column E
COMBOBOX 3 = Column B
COMBOBOX 4 = Column C
COMBOBOX 5 = Column D
COMBOBOX 6 = Column F
I use a small userform where comboboxes have values in a drop down that i then select from.
Sometimes when i click the drop down arrow the value i would like to use isnt there, as its new & never been used before.
So now i need to close the userform, add the values to the table where my values are stored & then start all over again.
Can we somehow allow a value to be added to the table if currently not present ?
The form opens up when i use the worksheet called X300 PRO 3 LIST
The values are stored on worksheet called DATABASE INFO
These comboboxes on the form relate to the column on the worksheet.
COMBOBOX 1 = Column A
COMBOBOX 2 = Column E
COMBOBOX 3 = Column B
COMBOBOX 4 = Column C
COMBOBOX 5 = Column D
COMBOBOX 6 = Column F
Rich (BB code):
Private Sub CommandButton1_Click()
Dim i As Integer
Dim ControlsArr As Variant, ctrl As Variant
Dim x As Long
For i = 1 To 6
With Me.Controls("ComboBox" & i)
If .ListIndex = -1 Then
MsgBox "MUST SELECT ALL OPTIONS", 48, "X300 IMMO LIST TRANSFER"
.SetFocus
Exit Sub
End If
End With
Next i
ControlsArr = Array(Me.ComboBox1, Me.ComboBox2, Me.ComboBox3, Me.ComboBox4, Me.ComboBox5, Me.ComboBox6)
With ThisWorkbook.Worksheets("X300 PRO 3 LIST")
.Range("A4").EntireRow.Insert Shift:=xlDown
.Range("A4:G4").Borders.Weight = xlThin
.Cells(4, "G") = TextBox1.Value
For i = 0 To UBound(ControlsArr)
Select Case i
Case 1, 2, 4
.Cells(4, i + 1) = IIf(IsNumeric(ControlsArr(i)), Val(ControlsArr(i)), ControlsArr(i))
Case Else
.Cells(4, i + 1) = ControlsArr(i)
ControlsArr(i).Text = ""
End Select
Next i
End With
Application.ScreenUpdating = False
With Sheets("X300 PRO 3 LIST")
If .AutoFilterMode Then .AutoFilterMode = False
x = .Cells(.Rows.Count, 1).End(xlUp).Row
.Range("A3:G" & x).Sort Key1:=Range("A4"), Order1:=xlAscending, Header:=xlGuess
End With
ActiveWorkbook.Save
Application.ScreenUpdating = True
Sheets("X300 PRO 3 LIST").Range("A4").Select
MsgBox "DATABASE HAS NOW BEEN UPDATED", vbInformation, "SUCCESSFUL MESSAGE"
Unload X300ImmoListForm
Range("A5").Select
Range("A4").Select
End Sub