Originally Posted by
Majad
What you mean? What did you do?
Oh nothing...
Completely unrelated, a program I wrote when I first started programming.
Code:
Private Sub CommandButton1_Click()
Frm_Entry.Show 'New entry
End Sub
Private Sub CommandButton2_Click()
Frm_Records.Hide 'Save/Close
SendKeys ("^s")
End Sub
Private Sub CommandButton3_Click()
Frm_Records.Hide 'Exit to sheets
End Sub
Private Sub OptionButton1_Click() 'Engineering
If OptionButton1.Value = True Then Worksheets("Engineering").Select
End Sub
Private Sub OptionButton2_Click() 'Office
If OptionButton2.Value = True Then Worksheets("Office").Select
End Sub
Private Sub OptionButton3_Click() 'Factory
If OptionButton3.Value = True Then Worksheets("Factory").Select
End Sub
Private Sub OptionButton4_Click() 'Dispatch
If OptionButton4.Value = True Then Worksheets("Dispatch").Select
End Sub
Private Sub OptionButton5_Click() 'Production
If OptionButton5.Value = True Then Worksheets("Production").Select
End Sub
Private Sub TextBox1_Change() 'Dispatch Filter
If OptionButton4.Value = True Then
Sheets("FilteredNames").Cells.ClearContents
For X = 1 To Sheets("Dispatch").Range("B" & Rows.Count).End(xlUp).Row
If UCase(Left(Sheets("Dispatch").Range("B" & X).Value, Len(TextBox1))) = UCase(TextBox1) Then
If Sheets("FilteredNames").Range("B1") = "" Then
Sheets("FilteredNames").Range("B1").Formula = Sheets("Dispatch").Range("B" & X).Text
Else
Sheets("FilteredNames").Range("B" & Rows.Count).End(xlUp).Offset(1, 0).Formula = Sheets("Dispatch").Range("B" & X).Text
End If
End If
Next
ListBox1.RowSource = "FilteredNames!B1:B" & Sheets("FilteredNames").Range("B" & Rows.Count).End(xlUp).Row
End If
End Sub
Private Sub CommandButton1_Click() 'Enter
Dim emptyRow As Long
If OptionButton1.Value = True Then Worksheets("Engineering").Select 'Engineering
If OptionButton2.Value = True Then Worksheets("Office").Select 'Office
If OptionButton3.Value = True Then Worksheets("Factory").Select 'Factory
If OptionButton4.Value = True Then Worksheets("Dispatch").Select 'Dispatch
If OptionButton5.Value = True Then Worksheets("Production").Select 'Production
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
Cells(emptyRow, 2).Value = TextBox1.Value 'Name
Cells(emptyRow, 3).Value = TextBox2.Value 'Reason
Cells(emptyRow, 4).Value = TextBox3.Value 'Date
Cells(emptyRow, 6).Value = TextBox4.Value 'Time
Cells(emptyRow, 7).Value = TextBox5.Value 'Date of docters appointment
Cells(emptyRow, 8).Value = TextBox6.Value 'Contact number
Cells(emptyRow, 9).Value = TextBox7.Value 'Callback
Cells(emptyRow, 10).Value = TextBox8.Value 'Date started
Cells(emptyRow, 11).Value = TextBox9.Value 'Dates absent
If OptionButton1.Value = True Then Cells(emptyRow, 1).Value = OptionButton1.Caption 'Engineering
If OptionButton2.Value = True Then Cells(emptyRow, 1).Value = OptionButton2.Caption 'Office
If OptionButton3.Value = True Then Cells(emptyRow, 1).Value = OptionButton3.Caption 'Factory
If OptionButton4.Value = True Then Cells(emptyRow, 1).Value = OptionButton4.Caption 'Dispatch
If OptionButton5.Value = True Then Cells(emptyRow, 1).Value = OptionButton5.Caption 'Production
If OptionButton6.Value = True Then Cells(emptyRow, 5).Value = OptionButton6.Caption 'Yes
If OptionButton7.Value = True Then Cells(emptyRow, 5).Value = OptionButton7.Caption 'No
Dim z As Control
For Each z In Frm_Entry.Controls
If TypeName(z) = "TextBox" Then
z.Value = ""
End If
Next z
MsgBox "Entry has been added."
End Sub
Private Sub CommandButton4_Click()
Frm_Entry.Hide 'Close
End Sub
iBored!