Hello everyone,
I am familiar with a few coding languages, including PHP, C++, etc, however I am new to Excel and VBA. I am attempting to create a do-while/do-until loop which stays in the same column, and keeps descending row to row until it hits a Gray-filled cell, at which point it takes the value of that cell and returns it. The data looks something like this:
<tbody>
</tbody>
(It was easier in this post to change the font color instead of the fill color, but you get the idea). Also, the number of rows between names varies. What I have written so far is this:
Should I use a function here, or sub? Also, I keep getting an "Application-defined or object-defined error" message. What am I doing wrong/is there an easier way?
Thanks in advance for any help with this, I greatly appreciate it!
I am familiar with a few coding languages, including PHP, C++, etc, however I am new to Excel and VBA. I am attempting to create a do-while/do-until loop which stays in the same column, and keeps descending row to row until it hits a Gray-filled cell, at which point it takes the value of that cell and returns it. The data looks something like this:
Sam | 4 | 7 | 34 | 4 | 3 | 5 | 8 |
5 | 4 | 44 | 34 | 5 | 8 | 5 | |
3 | 34 | 22 | 34 | 5 | 68 | 85 | |
Mark | 234 | 43 | 23 | 65 | 345 | 23 | 434 |
234 | 234 | 65 | 45 | 3 | 45 | 65 | |
745 | 4 | 5 | 63 | 345 | 4 | 3 |
<tbody>
</tbody>
(It was easier in this post to change the font color instead of the fill color, but you get the idea). Also, the number of rows between names varies. What I have written so far is this:
Code:
Function checkFill()
Dim i As Integer
Dim AHT As Integer
i = 0
Do While Cells(i, 5).Interior.ColorIndex > 0
If Cells(i, 5).Interior.ColorIndex = 16 Then
AHT = Cells(i, 5).Value
Exit Do
End If
i = i + 1
Loop
End Function
Should I use a function here, or sub? Also, I keep getting an "Application-defined or object-defined error" message. What am I doing wrong/is there an easier way?
Thanks in advance for any help with this, I greatly appreciate it!