In reference to this thread I am trying to sort groups of rows based on a single cell in each group.
I am going to try a brute force approach and run a loop that looks for the search criteria and copies this into a newly created first column for each of the rows in the group. I can then sort the groups using the first column.
The cell I am looking for is in column F of every row that contains "C" in column B. I need to take this value, copy it, then paste it to column A for the 4 rows that comprise the group. The rows are the two rows above the row with "C", the same row as the row with "C", and the row below the row with "C".
For example, I would need this code to find a value present in F3 and copy that value to A1:A4. I believe I would need to do this in relative terms as I am using a loop.
I have attached a worksheet that manually shows what I am starting with and what I want to acheive (one worksheet for each). Please keep in mind that the attached workbook is just for illustration and shows only two groups of data points; this would need to loop through any number of data points.
![]()
LastRow = Range("B65536").End(xlUp).Row For r = LastRow To 1 Step -1 With Range("B" & r) If .Value = "C" Then Range("F" & r).Select Selection.Copy 'How do I reference the cells to paste? ActiveSheet.Paste End If End With
Bookmarks