Hi
I want to find a specific cell on the same row as three different combobox values. So I want to find the row where column A is depending on combobox 1 column B on combobox 2 and C on combobox 3 and then I want the cell from Column D on the same row as those values. I have the following code which just gives me the cell depending on the first combobox which is not correct in the end:
I want to find a specific cell on the same row as three different combobox values. So I want to find the row where column A is depending on combobox 1 column B on combobox 2 and C on combobox 3 and then I want the cell from Column D on the same row as those values. I have the following code which just gives me the cell depending on the first combobox which is not correct in the end:
Code:
Dim rng1 As Range
Dim year As String
Dim rng2 As Range
Dim month As String
Dim rng3 As Range
Dim day As String
Dim rownumber As Long
year = ComboBox1.Value
month = ComboBox2.Value
day = ComboBox3.Value
Set rng1 = Sheets("Sheet2").Columns("A:A").Find(What:=year, LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
Set rng2 = Sheets("Sheet2").Columns("B:B").Find(What:=month, LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
Set rng3 = Sheets("Sheet2").Columns("C:C").Find(What:=day, LookIn:=xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
rownumber = rng1.Row
Sheets("Sheet1").Cells(1, 1) = Sheets("Sheet2").Cells(rownumber, 4)