Combobox selection to determine data entry range

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
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Forum statistics

Threads
1,214,983
Messages
6,122,598
Members
449,089
Latest member
Motoracer88

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