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