lundi 25 octobre 2021

insert xlookup among mulitple workbooks with multiple sheets wrapped in if/then statements

Need a review of the logic. 2 workbooks (for now) with 5 worksheets each. flag school's master with cases found under the RC HH export by team insert Columns for keepers with hearders to mitigate the filtered data and exact match concatenate establised for searcing on the source file need to perform match on dst file to src file and populate dst file with CMR filed form src file IF present do not overwrite any existing data in CMR column on dst file only address used rows on respective sheets for data conservation src and dst files are homed to sharepoint per microsoft cannot direct open to those files thru vba need to ensure the respective files are open on the user's desktop for this to run and no other users loogged in while executing office 365 environment

Sub Trial()  
    Dim src As String
    Dim dst As String
    Dim wbSource As Workbook
    Dim wbDest As Workbook
    Dim ALERT As String
    Dim Concatenate As String
    Dim FILLDATA As String
    Dim SOURCE As String
    Dim Head1 As String
    Dim Head2 As String
    Dim Check As Range
    Dim r As Long
    Dim lastrow2 As Long
    Dim lastrow As Long
    Dim N As Long

    
    src = "RC_SCH_SORTED_TODAY.xlsx"
    dst = "Copy Fall 2021_Schools_master list_8.24.21.xlsx"
    ALERT = "ALERT-RC-Match"
    Concatenate = "=RC[-47]&""-""&RC[-46]&""-""&RC[-45]"
    Head1 = "FLAG FOR PULL FROM RC EXPORT"
    Head2 = "Concatenated Search"
    FILLDATAMS = "=XLOOKUP(@AX:AX,wbSource[[#RC SPARKS],[Concatenated Search]],wbDest[[#SPARKS],[CMR'#]],,0) "
    FILLDATADC = "=XLOOKUP(@AX:AX,wbSource[[#RC DC],[Concatenated Search]],wbDest[[#DC],[CMR'#]],,0) "
    FILLDATADR = "=XLOOKUP(@AX:AX,wbSource[[#RC Danielle],[Concatenated Search]],wbDest[[#Danielle],[CMR'#]],,0) "
    FILLDATANC = "=XLOOKUP(@AX:AX,wbSource[[#RC Natalie],[Concatenated Search]],wbDest[[#Natalie],[CMR'#]],,0) "
    FILLDATAGH = "=XLOOKUP(@AX:AX,wbSource[[#RC Gabe],[Concatenated Search]],wbDest[[#Gabe],[CMR'#]],,0) "
    Set wbSource = Workbooks(src)
    Set wbDest = Workbooks(dst)
    
    Workbooks(src).Activate
    Workbooks(dst).Activate

'   sparks's team workload
     Sheets("SPARKS").Select
     Range("AW1").Value = Head1
     Range("AX1").Value = Head2
    
     Application.ScreenUpdating = False
     lastrow = Worksheets("SPARKS").UsedRange.Rows.Count
     N = Cells(Rows.Count, "C").End(x1Up).Row
     Range("AX2:AX" & N).Formula2R1C1 = Concatenate
     For r = lastrow To 2 Step -1


        If Worksheets("SPARKS").Range("AF" & r).Value = "" Then
            Worksheets("SPARKS").Cells("AF").Value = FILLDATAMS & Worksheets("SPARKS").Cells("AW") = ALERT
        Else
        End If
     Next r
     Application.ScreenUpdating = True

the break is in the logic within the if/then this is repeated among the other worksheets for their respective sources and i am stuck on the logic. I am not formally trained but have been tasked with working this out. I have multiple other workbooks to perform similar functions among for data consolidation to the support teams.

Aucun commentaire:

Enregistrer un commentaire