ReliableEngineer
New Member
- Joined
- Oct 26, 2017
- Messages
- 3
Hey everyone,
I am fairly new to VBA but am learning slowly. I
have a spreadsheet to monitor system temperatures. Each aircraft registration range contains 4 columns: Date, Green, Yellow, and PTU. I have created a simple userform to enter the data. This userform uses a combobox to show the required aircraft registration and textboxes for the date and temperature data. To enter the data I have a command button. The form does use "Clear" and "Close" command buttons. Currently the combobox data is being filled from a separate sheet named "Fleet".
Essentially I want the combobox to select which registration range to enter the data into the last row of the range on the active sheet named "Data".
Any help would be appreciated.
Cheers.
Here is my code so far:
Private Sub UserForm_Initialize()
'Empty RegoComboBox
RegoComboBox.Clear
'Fill RegoComboBox
Me.RegoComboBox.List = Worksheets("Fleet").Range("A2:A15").Value
'Empty DateTextBox
DateTextBox.Value = ""
'Empty Green textbox
GreenTextBox.Value = ""
'Empty Yellow textbox
YellowTextBox.Value = ""
'Empty PTU textbox
PTUTextBox.Value = ""
'Set Focus on RegoComboBox
RegoComboBox.SetFocus
End Sub
Private Sub ClearCommandButton_Click()
Call UserForm_Initialize
End Sub
Private Sub CloseCommandButton_Click()
Unload Me
End Sub
Private Sub EnterCommandButton_Click()
Dim emptyRow As Long
'Make Data page active
Worksheets("Data").Activate
'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
'Transfer information
Cells(emptyRow, 1).Value = DateTextBox.Value
Cells(emptyRow, 2).Value = GreenTextBox.Value
Cells(emptyRow, 3).Value = YellowTextBox.Value
Cells(emptyRow, 4).Value = PTUTextBox.Value
'Empty DateTextBox
DateTextBox.Value = ""
'Empty Green textbox
GreenTextBox.Value = ""
'Empty Yellow textbox
YellowTextBox.Value = ""
'Empty PTU textbox
PTUTextBox.Value = ""
'Set Focus on RegoComboBox
RegoComboBox.SetFocus
End Sub
I am fairly new to VBA but am learning slowly. I
have a spreadsheet to monitor system temperatures. Each aircraft registration range contains 4 columns: Date, Green, Yellow, and PTU. I have created a simple userform to enter the data. This userform uses a combobox to show the required aircraft registration and textboxes for the date and temperature data. To enter the data I have a command button. The form does use "Clear" and "Close" command buttons. Currently the combobox data is being filled from a separate sheet named "Fleet".
Essentially I want the combobox to select which registration range to enter the data into the last row of the range on the active sheet named "Data".
Any help would be appreciated.
Cheers.
Here is my code so far:
Private Sub UserForm_Initialize()
'Empty RegoComboBox
RegoComboBox.Clear
'Fill RegoComboBox
Me.RegoComboBox.List = Worksheets("Fleet").Range("A2:A15").Value
'Empty DateTextBox
DateTextBox.Value = ""
'Empty Green textbox
GreenTextBox.Value = ""
'Empty Yellow textbox
YellowTextBox.Value = ""
'Empty PTU textbox
PTUTextBox.Value = ""
'Set Focus on RegoComboBox
RegoComboBox.SetFocus
End Sub
Private Sub ClearCommandButton_Click()
Call UserForm_Initialize
End Sub
Private Sub CloseCommandButton_Click()
Unload Me
End Sub
Private Sub EnterCommandButton_Click()
Dim emptyRow As Long
'Make Data page active
Worksheets("Data").Activate
'Determine emptyRow
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
'Transfer information
Cells(emptyRow, 1).Value = DateTextBox.Value
Cells(emptyRow, 2).Value = GreenTextBox.Value
Cells(emptyRow, 3).Value = YellowTextBox.Value
Cells(emptyRow, 4).Value = PTUTextBox.Value
'Empty DateTextBox
DateTextBox.Value = ""
'Empty Green textbox
GreenTextBox.Value = ""
'Empty Yellow textbox
YellowTextBox.Value = ""
'Empty PTU textbox
PTUTextBox.Value = ""
'Set Focus on RegoComboBox
RegoComboBox.SetFocus
End Sub