I am learning vba on my own as I go and I'm currently stuck on how to use the following formula in vba:
=INDEX('C:\Users\Desktop\[Backlog.xlsx]backlog1'!$J:$J,MATCH(1, (A2='C:\Users\Desktop\[Backlog.xlsx]backlog1'!$W:$W)*(B2='C:\Users\Desktop\[Backlog.xlsx]backlog1'!$AE:$AE),0))
Followed by Crtl+Shift+Enter. The formula uses data from another workbook, in some cases the result can be a duplicate value or #N/A, that is okay as I am trying to find those instances when it doesn't match but the purpose is to get the matching value. However, what I have now of code simply doesn't even display a value.
Windows("Book1.xlsm").Activate
Range("F2").Select
Dim wb2 As Workbook
Dim w2 As Worksheet
Dim sales As Range
Set wb2 = Workbooks.Open(Filename:="C:\Users\Desktop\Backlog.xlsx", UpdateLinks:=0)
Set w2 = wb2.Worksheets("backlog1")
Set sales = wb2.w2.Range("J:J")
Dim res As Variant
res = Application.Match("A2", sales, 0)
If IsError(res) Then
ActiveCell.Value = "N/A"
Else
ActiveCell.Value = res
End If
Dim answer As Long
answer = WorksheetFunction.Index(sales, res)
Set x = Evaluate(answer)
If IsError(x) Then
ActiveCell.Value = x
Else
ActiveCell.Value = "N/A"
End If
In that code I am barely attempting to get a simple index/match thing going before attempting to do what the actual excel formula should do. Thanks in advance!! :)
Aucun commentaire:
Enregistrer un commentaire