Forum Discussion
fredc2022
Apr 28, 2022Brass Contributor
VBA Find (What:="") tied to dropdown list box
In the VBA Find(What:=), I want the What:=" " to get it's value from a drop down list box in sheet1. I have two worksheets, 1) sheet with three dropdown list boxes 2) sheet with unstructured data w...
- May 02, 2022
Hi Fred,
I see the mistake that I made. I hope that the attached version works correctly. You'll notice that there is no Teams dropdown anymore. It isn't needed because the macro loops through all teams.
You only need to select a week, then click the button.
fredc2022
May 01, 2022Brass Contributor
Hello Hans,
Thanks for the cursor tip. Didn't know that. Still don't under stand why I can't see the cell that the code is referring to. I'm assuming that is because it doesn't call for "select" or "activate." Is that correct?
Please advise where this is in the "DROPDOWNLISTBOX";
' Find week on DROPDOWNLISTBOX
Set rg = wt.Range("3:3").Find(What:=wk, LookAt:=xlWhole, MatchCase:=False)
Not sure where the cell is unless it's starts at "A1". I don't see where that gets us.
I'm playing with the code to see where each piece is on the worksheet.
Thanks for hanging in with me. I'm going to try to be up at your post times tonight.
Thanks for the cursor tip. Didn't know that. Still don't under stand why I can't see the cell that the code is referring to. I'm assuming that is because it doesn't call for "select" or "activate." Is that correct?
Please advise where this is in the "DROPDOWNLISTBOX";
' Find week on DROPDOWNLISTBOX
Set rg = wt.Range("3:3").Find(What:=wk, LookAt:=xlWhole, MatchCase:=False)
Not sure where the cell is unless it's starts at "A1". I don't see where that gets us.
I'm playing with the code to see where each piece is on the worksheet.
Thanks for hanging in with me. I'm going to try to be up at your post times tonight.
HansVogelaar
May 01, 2022MVP
The code intentionally does not select cells, because a macro runs much more efficiently if it does not.
The line
Set rg = wt.Range("3:3").Find(What:=wk, LookAt:=xlWhole, MatchCase:=False)
looks for the week in row 3. Since we don't specify where to begin, it starts from the first cell in row 3, i.e. A3.
I'm going to single-step through the macro again to see if I can detect an error.