Dim WS As Worksheet
Private Sub Button_Cancel_Click()
Unload Me
Sheets("background").Visible = False
Sheets("Summary").Select
End Sub
Private Sub Button_Enter_Click()
Dim Ctrl As MSForms.Control
Dim CtrlArray As Variant
Dim CtrlType As String
Dim Msg As String
Dim ReturnTo As String
If CheckBox1.Value = True Then
CtrlArray = Array("TextBox1", "TextBox2", "TextBox3", "TextBox4", _
"TextBox5", "TextBox6", "TextBox7", "TextBox8", _
"Combo_Client", "Combo_Firm", "Combo_Sport")
For Each Ctrl In Me.Controls
CtrlType = TypeName(Ctrl)
If CtrlType Like "TextBox*" Or CtrlType Like "Combo*" Then
If Ctrl.Value = "" Then
Msg = Msg & Switch(Ctrl.Name = CtrlArray(0), "Date", _
Ctrl.Name = CtrlArray(1), Label_Stake.Caption, _
Ctrl.Name = CtrlArray(2), "Avg.Price", _
Ctrl.Name = CtrlArray(3), "Phone Position", _
Ctrl.Name = CtrlArray(4), "Event/Market", _
Ctrl.Name = CtrlArray(5), "Hedging Reason", _
Ctrl.Name = CtrlArray(6), "Selection", _
Ctrl.Name = CtrlArray(7), "Returns", _
Ctrl.Name = CtrlArray(8), "Client", _
Ctrl.Name = CtrlArray(9), "Firm", _
Ctrl.Name = CtrlArray(10), "Event Class") & vbCrLf
If ReturnTo = "" Then ReturnTo = Ctrl.Name
End If
End If
Next Ctrl
End If
If CheckBox1.Value = False Then
If TextBox1.Value = "" Then Msg = "Date" & vbCrLf
If TextBox2.Value = "" Then Msg = Msg & Label_Stake.Caption & vbCrLf
If TextBox3.Value = "" Then Msg = Msg & "Avg. Price" & vbCrLf
If TextBox7.Value = "" Then Msg = Msg & "Selection" & vbCrLf
If TextBox5.Value = "" Then Msg = Msg & "Event/Market" & vbCrLf
If Combo_Sport.Value = "" Then Msg = Msg & "Event Class" & vbCrLf
If Combo_Client.Value = "" Then Msg = Msg & "Client Name" & vbCrLf
If TextBox4.Value = "" Then Msg = Msg & "Phone Position" & vbCrLf
If Combo_Firm.Value = "" Then Msg = Msg & "Firm Used" & vbCrLf
If TextBox6.Value = "" Then Msg = Msg & "Hedging Reason" & vbCrLf
End If
If Me.Option_Back.Value = False And Me.Option_Lay.Value = False Then _
Msg = Msg & "Bet Type (Back or Lay)" & vbCrLf
If Msg <> "" Then
MsgBox "The following information is missing:" & vbCrLf & vbCrLf & Msg
Exit Sub
End If
ScrOff
If Me.CheckBox1.Value = True Then
Set WS = Worksheets("Settled Hedges")
Fullsheet
Else
Set WS = Worksheets("Unsettled Hedges")
Fullsheet
End If
Set WS = Worksheets("Session Log")
Fullsheet
Unload Me
Sheets("background").Visible = False
Sheets("Summary").Select
End Sub
Private Sub Button_NewClient_Click()
ScrOff
frmInput.Hide
frmNewClient.Show
End Sub
Private Sub Button_NewSport_Click()
ScrOff
frmInput.Hide
frmNewSport.Show
End Sub
Private Sub Calendar1_Click() '###
CalShow
End Sub
Private Sub TextBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
CalShow
End Sub
Private Sub CalShow()
ScrOff
frmInput.Hide
With frmCalendar
.Show
With .Calendar1
Me.TextBox1.Text = VBA.Format(DateSerial(.Year, .Month, .Day), "DD/MM/YYYY")
End With
End With
frmInput.Show
End Sub '###
Private Sub UserForm_Activate()
ScrOff
Combo_Client.List = Sheets("Summary").Range("B7:B43").Value
Combo_Firm.List = Sheets("Summary").Range("N7:N43").Value
Combo_Sport.List = Sheets("Summary").Range("H7:H43").Value
End Sub
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
TextBox8.Visible = True
Label8.Visible = True
End If
If CheckBox1.Value = False Then
TextBox8.Visible = False
Label8.Visible = False
End If
End Sub
Private Sub CommandButton2_Click()
ScrOff
frmInput.Hide
frmNewFirm.Show
End Sub
Private Sub Option_Back_Click()
If Option_Back.Value = True Then
Label_Stake.Caption = "Stake"
TextBox2.ControlTipText = "Enter stake"
TextBox8.ControlTipText = "Returns after any commission inclusive of stake"
End If
End Sub
Private Sub Option_Lay_Click()
If Option_Lay.Value = True Then
Label_Stake.Caption = "Liability"
TextBox2.ControlTipText = "Enter liability"
TextBox8.ControlTipText = "Returns after any commission inclusive of liability"
End If
End Sub
Private Sub ScrOff()
'Application.ScreenUpdating = False
End Sub
Private Sub Fullsheet()
Dim iRow As Long
With WS
iRow = .Cells(.Rows.Count, 1).End(xlUp).Offset(1, 0).Row
.Cells(iRow, 1).Value = Me.TextBox1.Text '###
If Option_Back.Value = True Then
.Cells(iRow, 2).Value = "Back"
End If
If Option_Lay.Value = True Then
.Cells(iRow, 2).Value = "Lay"
End If
.Cells(iRow, 3).Value = Me.TextBox2.Value
.Cells(iRow, 4).NumberFormat = "@"
.Cells(iRow, 4).Value = Me.TextBox3.Value
.Cells(iRow, 5).Value = Me.TextBox7.Value
.Cells(iRow, 6).Value = Me.TextBox5.Value
.Cells(iRow, 7).Value = Me.Combo_Sport.Value
.Cells(iRow, 8).Value = Me.Combo_Client.Value
.Cells(iRow, 9).Value = Me.TextBox4.Value
.Cells(iRow, 10).Value = Me.Combo_Firm.Value
.Cells(iRow, 11).Value = Me.TextBox6.Value
If CheckBox1.Value = True Then
.Cells(iRow, 12).Value = Me.TextBox8.Value
End If
If CheckBox1.Value = False Then
.Cells(iRow, 12).Value = "Unsettled"
End If
End With
Set WS = Nothing
End Sub
cheers
Bookmarks