Find cell value

MrThor

New Member
Joined
Aug 13, 2018
Messages
36
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:

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)
 
The "Resize(, 4)" expands the range to search to columns A to D not just column A. If it's not working for you, do you get an error message? If so, what is the error and which line of code is highlighted when you click "Debug"? Better still, it would be easier to help and test possible solutions if I could work with your actual file which includes any macros you are currently using. Perhaps you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Include a detailed explanation of what you would like to do using a few examples from your data and referring to specific cells, rows, columns and worksheets. If the workbook contains confidential information, you could replace it with generic data.
 
Upvote 0

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hi, If I want to use your code but change the value in combobox2 to a text value (ie. "january") instead of a number, how do I do that? For now it does only work with numbers.

Regards
 
Upvote 0
Does Column B contain a text value like "January" or does it still contain a number?
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,217
Members
453,024
Latest member
Wingit77

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