Run time error 1004

gheyman

Well-known Member
Joined
Nov 14, 2005
Messages
2,341
Office Version
  1. 365
Platform
  1. Windows
This is causing an error on these two rows. Not sure why. I checked the names in the formula and everything looks OK from what I see

Sheets("PT Material Assoc Costs").ListObjects("PT_MaterialAssocCosts").ListColumns("Mtrl Consolidation").DataBodyRange.FormulaR1C1 = "=XLOOKUP([@[TASK ID]],PQ Cost Source[TASK ID],PQ Cost Source[Mtrl Consolidation])"

Sheets("PT Material Assoc Costs").ListObjects("PT_MaterialAssocCosts").ListColumns("Vendor Name").DataBodyRange.FormulaR1C1 = "=XLOOKUP([@[Ref ID]],PQ_Material_Assoc_Costs[Ref ID],PQ_Material_Assoc_Costs[Vendor Name])"

Code:
Sub CreatePivotTableMaterialAssocCost()

'Clear the PT Table

Sheets("PT Material Assoc Costs").Visible = True

    Dim CLR33 As Long
    
    CLR33 = Sheets("PT Material Assoc Costs").Cells(Rows.Count, "A").End(xlUp).Row
    If CLR33 > 2 Then Sheets("PT Material Assoc Costs").Range("A3:AB" & CLR33).ClearContents


'Move Data from the PP Template Material Assoc Cost to create a table for PQ.  This is needed so that the Consolidate Material ID can be added.
    Dim PPLR3 As Long
    PPLR3 = Sheets("Material Assoc Costs").Cells(Rows.Count, "A").End(xlUp).Row
    
    Sheets("PT Material Assoc Costs").Select
    Columns("Y:APN").Select
    Selection.Delete Shift:=xlToLeft
     

'Copy from PP template
    Sheets("Material Assoc Costs").Range("A2:X" & PPLR3).Copy Sheets("PT Material Assoc Costs").Range("A1")
    
 'Add a new column at the end
    With Sheets("PT Material Assoc Costs").ListObjects("PT_MaterialAssocCosts").HeaderRowRange
        With .Offset(0, .Count).Resize(1, 2)
            .Value = Array("Mtrl Consolidation", "Vendor Name")
            .EntireColumn.AutoFit
        End With
    End With
    
Sheets("PT Material Assoc Costs").Select
    
    Sheets("PT Material Assoc Costs").ListObjects("PT_MaterialAssocCosts").ListColumns("Mtrl Consolidation").DataBodyRange.FormulaR1C1 = "=XLOOKUP([@[TASK ID]],PQ Cost Source[TASK ID],PQ Cost Source[Mtrl Consolidation])"
    Sheets("PT Material Assoc Costs").ListObjects("PT_MaterialAssocCosts").ListColumns("Vendor Name").DataBodyRange.FormulaR1C1 = "=XLOOKUP([@[Ref ID]],PQ_Material_Assoc_Costs[Ref ID],PQ_Material_Assoc_Costs[Vendor Name])"

    Sheets("Step 5").Select
    Sheets("Step 5").PivotTables("PivotTable2").PivotCache.Refresh


End Sub
Any help is appreciated
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
The first line can't be the right formula as you have spaces in the source table name.
 
Upvote 0
Solution
Thanks, Rory. Sometimes its right in front of your face and you don't see it. Thank you!
 
Upvote 0

Forum statistics

Threads
1,214,901
Messages
6,122,157
Members
449,068
Latest member
shiz11713

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top