H
Howard
From the list of items in column A, find each (if they exist) in Range("B2:F7") and list the header of that column (B1:F1) in column J. Column A items can occur under multiple headers in B1 to F1.
I'm sure this is the culprit line...
..Range("J100").End(xlUp).Offset(1, 0) = i.Offset(Cells.End(xlUp), 0).Value
Secondly, in column J where the header is listed, I am struggling to get the cell address of "i" next to header name in column K.
So an example would be in col J = Col_B_Header and in col K = $B$5
Regards,
Howard
Option Explicit
Sub ListHeader()
Dim lngLstRow As Long
Dim rngA As Range, i As Range
With Sheets("Sheet2")
lngLstRow = .UsedRange.Rows.Count
For Each rngA In .Range("A2:A" & lngLstRow)
For Each i In Range("B2:F7")
If i.Value = rngA Then
.Range("J100").End(xlUp).Offset(1, 0) _
= i.Offset(Cells.End(xlUp), 0).Value
End If
Next
Next
End With
End Sub
I'm sure this is the culprit line...
..Range("J100").End(xlUp).Offset(1, 0) = i.Offset(Cells.End(xlUp), 0).Value
Secondly, in column J where the header is listed, I am struggling to get the cell address of "i" next to header name in column K.
So an example would be in col J = Col_B_Header and in col K = $B$5
Regards,
Howard
Option Explicit
Sub ListHeader()
Dim lngLstRow As Long
Dim rngA As Range, i As Range
With Sheets("Sheet2")
lngLstRow = .UsedRange.Rows.Count
For Each rngA In .Range("A2:A" & lngLstRow)
For Each i In Range("B2:F7")
If i.Value = rngA Then
.Range("J100").End(xlUp).Offset(1, 0) _
= i.Offset(Cells.End(xlUp), 0).Value
End If
Next
Next
End With
End Sub