I have two TextBox in my userform. One is for entering the Name, and the other one is for entering the income.
Now I create a modeless userform, so that user can keep insert the data
Suppose I already have list of Name. For example: Marry, Jamie, Michael
Is it posible to set this list as a default value for Name TextBox? For example:
After click the button, the userform Pop up and Shows as follow:
Name: Marry
Income: ""
After I enter the income, and click "OK" buttom, the userform will Pop up again. This time it Shows like this:
Name: Jamie
Income: ""
If my question is not clear enough, please tell me and I will explain it more detailed. Thanks in advance.
Update:
I add my code here to make my question clearer. However, the "story" of my code is a Little bit different. The user will insert the Portfolio ID, Budget value and the date into userform. Then the macro will filter the table in sheet "ALL_List".
Based on Portfolio ID and date, there will be only one line data in that table after filtering. The Budget column for this line of data should be empty. The Macro should automatically insert the Budget value, which was recorded in userform, into Budget column.
There are, for example, 5 ID and 5 Budget value:
Date / ID / Budget
29/06/2018 / 12541 / 336521
29/06/2018 / 4521 / 658882
29/06/2018 / 44359 / 4587996
29/06/2018 / 10223 / 148665
29/06/2018 / 74 / 658324
So, when the first time userform Pop up. I hope there will be a Default ID value "12541" in the Portfolio ID TextBox. After I enter the date and Budget value and click the button "Enter", the Budget value will insert to the Budget column in sheet "ALL_List". Then the userform Pop up again. This time the Default value for ID will be 4521.
After the final Default ID (74) Show up and I enter the value and click Enter, I hope the userform will still Pop up and this time the value of Portfolio ID TextBox will be empty (because there could be other ID which the user wants to insert.)
Hope my descripition is clear. If there is any question, please don't hesitate to inform me. Much Thanks!
Sub Budget_Adjustment()
Dim frm As New UserFormBudget
frm.Show vbModeless
End Sub
Private Sub ButtonClose_Click()
Unload Me
End Sub
Private Sub ButtonEnter_Click()
InsertBudget
End Sub
Private Sub InsertBudget()
Dim UpdateDate As String
Dim PortfolioID, Budgetvalue As Long
UpdateDate = TextBoxDate.Value
PortfolioID = TextBoxID.Value
Budgetvalue = TextBoxBedget.Value
UpdateDate = CDate(UpdateDate)
Sheets("ALL_List").Activate
ActiveSheet.AutoFilterMode = False
Range(Cells(1, 1), Cells(Cells(Rows.Count, 7).End(xlUp).row, 7)).AutoFilter Field:=1, Criteria1:=UpdateDate
Range(Cells(1, 1), Cells(Cells(Rows.Count, 7).End(xlUp).row, 7)).AutoFilter Field:=3, Criteria1:=PortfolioID
Cells(Cells(Rows.Count, "A").End(xlUp).row, "F").Value = Budgetvalue
ActiveSheet.AutoFilterMode = False
TextBoxID.Value = ""
TextBoxBedget.Value = ""
TextBoxID.SetFocus
End Sub
Private Sub TextBoxBedget_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Then
ButtonEnter_Click
End If
End Sub
Private Sub UserForm_Activate()
'Empty TextBoxID
TextBoxID.Value = ""
'Empty TextBoxBedget
TextBoxBedget.Value = ""
'Empty TextBoxDate
TextBoxDate.Value = ""
'Set Focus on NameTextBox
TextBoxDate.SetFocus
End Sub
