So I have a working code that uses xlookups to pull values from one table to another. That I can do and my code works fine. For reference here's the working code:
However, I was wondering if there is a better way to write this using relationships.
I would like to set CCC_Employees[Genesys ID] as the primary key with the foreign key being [agent name] so that I could then do something like:
Not sure if this is possible, or worth the effort of doing but my full code is full of xlookups that I feel could be replaced with relationships if only I knew how. I'm looking for the most efficient method as I'm working in VERY large datasets so any advice would be greatly appreciated! Thanks in advance
VBA Code:
Option Explicit
Dim RT As ListObject, PTO As ListObject, Tot As ListObject, C3 As ListObject
Dim WS As Worksheet
Sub Review_Time()
Sheets("Genesys").Activate
Set WS = ActiveSheet
Set Tot = WS.ListObjects(1)
With Tot
.ListColumns("CMS Name").DataBodyRange.Formula2 = "=Xlookup([@[Agent Name]],CCC_Employees[GenesysID],CCC_Employees[CMS Name])"
.ListColumns("Employee ID").DataBodyRange.Formula2 = "=xlookup([@[Agent Name]],CCC_Employees[GenesysID],CCC_Employees[Employee ID])"
With .ListColumns.Add
.Name = "Department"
.DataBodyRange.Formula2 = "=xlookup([@[agent name]],CCC_Employees[GenesysID],CCC[Department])"
End With
End Sub
However, I was wondering if there is a better way to write this using relationships.
I would like to set CCC_Employees[Genesys ID] as the primary key with the foreign key being [agent name] so that I could then do something like:
VBA Code:
.listcolumns("CMS Name").databodyrange = CCC_Employees[CMS Name]
.listcolumns ("Employee ID").databodyrange = CCC_Employees[Employee ID]
.listcolumns("Deparment").databodyrange = CCC_Employees[Department]
Not sure if this is possible, or worth the effort of doing but my full code is full of xlookups that I feel could be replaced with relationships if only I knew how. I'm looking for the most efficient method as I'm working in VERY large datasets so any advice would be greatly appreciated! Thanks in advance