Err: worksheetfunction.vlookup:Unable to get the vlookup property
Hej!Jeg ønsker at udføre en vlookup baseret på en "for each" iterering af et range af celler i en pivot-tabel. (Jeg anvender Excel XP, engelsk.)
Men jeg kan ikke anvende "worksheetfunction.vlookup" i min VBA kode. Fejlen er som følger:
"Unable to get the Vlookup property of the Worksheetfunction class."
Dette er den specifikke kode som fejler:
myTarget.Offset(j, -1) = c.PivotCell.RowItems.Item(1)
myTarget.Offset(j, 0) = c.PivotCell.RowItems.Item(2)
myTarget.Offset(j, 1) = c.Offset(0, -1).Value
myTarget.Offset(j, 2) = Application.WorksheetFunction.VLookup(c.PivotCell.RowItems.Item(2), Worksheets("Softwarelist").Range("C:E"), 3, False)
--------------------------------------------------
Her er hele koden i sin helhed:
Sub PopulateCountSheet()
Dim c As Range
Dim j As Integer
Dim k As Integer
Dim myTarget As Range
Dim continueTarget As Range
Dim toSheetNeeded As Worksheet
Dim toSheetNotNeeded As Worksheet
Dim antal As Integer
Worksheets("Focus List YesNoPivot").Activate
Set toSheetNotNeeded = ThisWorkbook.Worksheets("Software NOT NEEDED")
Set myTarget = toSheetNotNeeded.Range("B65536").End(xlUp).Offset(9, 0)
ActiveSheet.PivotTables("PivotNeeded").Update
ActiveSheet.PivotTables("PivotNeeded").PivotSelect "yes", xlDataOnly
j = 0
For Each c In Selection
If (c.Value = "" Or c.Value = 0) Then
'Debug.Print c.Address
myTarget.Offset(j, -1) = c.PivotCell.RowItems.Item(1)
myTarget.Offset(j, 0) = c.PivotCell.RowItems.Item(2)
myTarget.Offset(j, 1) = c.Offset(0, -1).Value
myTarget.Offset(j, 2) = Application.WorksheetFunction.VLookup(c.PivotCell.RowItems.Item(2), Worksheets("Reducing Complexi SoftwareList").Range("C:E"), 3, False)
'VLOOKUP(c.PivotCell.RowItems.Item(2)'Reducing Complexi SoftwareList'!A:E,5,false)"
j = j + 1
End If
Next
Debug.Print "Done with populate count sheet."
End Sub
