When using the Intersect method, do the column and row have to be selected to work correctly?
Here's something similar to what I am using:
I can't get the Intersect to work to obtain the value in the intersect of the two ranges. What am I doing wrong?Function Productivity(date1 as Range, name1 As Range) Application.Volatile True Application.ScreenUpdating = False Dim dateCol as Variant Dim nameRow as Variant Dim dateRng as Variant Dim nameRng as Variant Dim Total as Long Dim val as Long Total = 0 On Error Resume Next For each cell in Sheets("Sheet1").Cels.Range("A4:A31") If cell.value = name1.value then nameRng = cell.address(0,0) nameRow = Range(nameRng).Row Else 'Nothing End If Next Cell For each cell in sheets("Sheet1").Cells.Range("B1:HA1") If cell.value = date1.Value then dateRng = cell.Address(0,0) dateCol = Range(dateRng).Column Else 'Nothing End If Next Cell val = Intersect(dateCol, nameRow).Value Productivity = val End Function
*Note: date1 and name1 are the arguements for the function. In the ranges given for sheet1 (in the VBE) if the arguements' contents match the cell's value, then obtain what column and row they are in. And then obtain the value in the intersect of that row and column.







Reply With Quote