ComboBox issue

Brian R Armstrong

Board Regular
Joined
Jun 5, 2007
Messages
92
The code below only enters values when I exit the userform - unload/hide the userform

When I add a message box routine the values are stored i.e. enters multiple entries when I unload/hide the userform.
the
How can I change the code below to enter values on the command button and leave the userform on the screen using the message box for next entry.

I have been trying to resolve this for weeks - I can get by with what I have - but would really like to have a combo box fit for purpose. Any help would be greatly appreciated.

Many Thanks Brian A

Option Explicit
Private Sub BtnClose_Click()
Unload Me
End Sub

Private Sub BtnEnter_Click()

Dim reply
reply = MsgBox("Enter another Name?", vbYesNo, _
"Spend")

If reply = vbYes _
Then

Else
Frm_Spend.Hide
End If

ComboBox1.Text = ComboBox1.List(0)
Sheets("List").Select

End Sub

Private Sub ComboBox1_Change() 'THESE ARE OFFSET VALUES
Dim result As Range, x As Integer, CtrlSrc As String
Dim c14 As Integer
Dim c13 As Integer
On Error Resume Next
Set result = SearchRange.Find(ComboBox1.Text, , xlValues, xlWhole)

For x = 12 To 12

If result <> "Name" Then
CtrlSrc = result.Parent.Name & "!" & result.Offset(, x).Address

c13 = result.Offset(0, 13).Value
c14 = result.Offset(0, 14).Value
result.Offset(0, 12).Value = tb_12
result.Offset(0, 13).Value = tb_12 + c13
result.Offset(0, 14).Value = c14 + tb_12
result.Offset(0, 22).Value = result.Offset(0, 14) + result.Offset(0, 15) + result.Offset(0, 19) + result.Offset(0, 21)
result.Offset(0, 23).Value = "=rc[-10]=rc[-1]"
End If

With Me.Controls("TextBox" & CStr(x))
.ControlSource = CtrlSrc
End With
Next

If result <> "Name" Then
Dim lastrow As Long
Sheets("Actions").Select
lastrow = Worksheets("Actions").Range("A65536").End(xlUp).Row + 1
Cells(lastrow, 1).Value = result
Cells(lastrow, 2).NumberFormat = "dd/mmm/yy"
Cells(lastrow, 2).Value = tb_TDate
Cells(lastrow, 4).Value = tb_12

End If

End Sub
Private Sub UserForm_Initialize()
Dim R As Range
Set SearchRange = ThisWorkbook.Names("SearchRange").RefersToRange
For Each R In SearchRange
ComboBox1.AddItem R.Text
Next
'ComboBox1.Text = ComboBox1.List(0)

End Sub
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,225,662
Messages
6,186,290
Members
453,348
Latest member
newbieBA

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top