Search code examples
vbaexcelintersect

Vba intersection of heading row and column of target cell to get the heading of column


I am trying to get the column of the active cell and then find its intersection with the named range.

Sheet1.cells(3,5).value = Sheet2.cells(Intersect(Range("rngHeadingRowofSheet"), Target.Column)).Value

Target is the active cell whose column it will take and find the value of intersected cell with heading row named range.

But am getting type mismatch error. Can someone please help?


Solution

  • Try this:

    Sheet1.Cells(3,5).Value = Intersect(Sheet2.Range("rngHeadingRowofSheet"), Target.EntireColumn).Value