Forum Discussion
mnirx
Sep 20, 2022Copper Contributor
how do I identify specific cell of column referenced in formula?
For illustration purposes, I created a super simplified version (Table 1) of what I am doing. The data set I am actually working with is much larger, thus, the need to identify which cells it is usin...
- Sep 20, 2022
Do you want to return the cells which add up to 72? In your example that would be cells B4, B5, B6, B7, B8, B9, B10, B11 and B12.
With these lines of code you can return the cells. In the attached file you can click the button in cell J2. The cells are listed in column H. The macro works for any number of rows.
Sub reference_cells() Dim i, j, k As Long Range("H:H").Clear i = Range("A" & Rows.Count).End(xlUp).Row k = 1 For j = 1 To i If Cells(j, 1).Value > Cells(1, 4).Value Then Cells(k, 8).Value = "B" & j k = k + 1 Else End If Next j End Sub
OliverScheurich
Sep 20, 2022Gold Contributor
Do you want to return the cells which add up to 72? In your example that would be cells B4, B5, B6, B7, B8, B9, B10, B11 and B12.
With these lines of code you can return the cells. In the attached file you can click the button in cell J2. The cells are listed in column H. The macro works for any number of rows.
Sub reference_cells()
Dim i, j, k As Long
Range("H:H").Clear
i = Range("A" & Rows.Count).End(xlUp).Row
k = 1
For j = 1 To i
If Cells(j, 1).Value > Cells(1, 4).Value Then
Cells(k, 8).Value = "B" & j
k = k + 1
Else
End If
Next j
End Sub
mnirx
Sep 21, 2022Copper Contributor
Thank you so much. This helps a lot. I appreciated your patience as I provided further detail and the time you took to respond. Hope you have a good day and that the rest of your week goes well.