Forum Discussion
asantos2021
Nov 25, 2021Copper Contributor
Why is this VBA code populating only the first occurrence found in the range?
Hello, The idea is to get the selected value, which is a date, and look for occurrences in a range matching that date and then load them into a listbox. Here's what I've got so far, but: 01 - I...
- Nov 25, 2021
1) Change
myList(2, n) = r.Offset(, -1).Value
to
myList(2, n) = Format(r.Offset(, -1).Value, "hh:mm")
2) There are no duplicate dates in PartsData column C (please note that C5 is in 2020 and C7 is in 2021).
If there are duplicate dates, the list box will display all of them.
HansVogelaar
Nov 25, 2021MVP
Could you attach a small sample workbook without sensitive data?
- asantos2021Nov 25, 2021Copper Contributor
Here it is! Thanks a lot!
- HansVogelaarNov 25, 2021MVP
1) Change
myList(2, n) = r.Offset(, -1).Value
to
myList(2, n) = Format(r.Offset(, -1).Value, "hh:mm")
2) There are no duplicate dates in PartsData column C (please note that C5 is in 2020 and C7 is in 2021).
If there are duplicate dates, the list box will display all of them.
- asantos2021Nov 25, 2021Copper ContributorThat did work! Thanks a lot. Now...this is not updating, getting the rows added to the bottom of the range. Not expecting you to spend more time on it, as you've helped a lot already...just thinking out loud