Hello everyone,
I am currently learning VBA and I am trying to do an userform for my internship.
I made one and what I am trying to do is to fill multiple textboxes based on my combobox.
If I choose the game Fifa 12, I would like the textboxes filled based on my previously excel worksheet (with the help of some lookup maybe). The result should be like this (I typed manually in the textbox to show you):
I tried to search and I don't know if it is possible to do so, I found a code on the forum that I tried to do it but unfortunately it only fills the first value of the excel sheet:
I also found a FormulaArray but I didn't quite understand.
Thank you in advance for your help and I hope you will understand what I am trying to do.
I am currently learning VBA and I am trying to do an userform for my internship.
I made one and what I am trying to do is to fill multiple textboxes based on my combobox.
If I choose the game Fifa 12, I would like the textboxes filled based on my previously excel worksheet (with the help of some lookup maybe). The result should be like this (I typed manually in the textbox to show you):
I tried to search and I don't know if it is possible to do so, I found a code on the forum that I tried to do it but unfortunately it only fills the first value of the excel sheet:
Code:
Private Sub cboConsol_Change()
txtNintendoSales.Value = FindName(cboGames.Value)
txtSonySales.Value = FindName(cboGames.Value)
txtMicrosoftSales.Value = FindName(cboGames.Value)
txtNintendoConsole.Value = FindName(cboGames.Value)
txtSonyConsole.Value = FindName(cboGames.Value)
txtMicrosoftConsole.Value = FindName(cboGames.Value)
End Sub
Public Function FindName(Games) As String
With Worksheets("subscriptions").Range("B:B")
Set C = .Find(Games, LookIn:=xlValues, lookat:=xlWhole)
If Not C Is Nothing Then
FindName = C.Offset(0, 2).Value
Else
FindName = "Not Found"
End If
End With
End Function
I also found a FormulaArray but I didn't quite understand.
Thank you in advance for your help and I hope you will understand what I am trying to do.