gheyman
Well-known Member
- Joined
- Nov 14, 2005
- Messages
- 2,341
- Office Version
- 365
- Platform
- Windows
I am getting a run-time error '91': Object variable or With block variable not set
on this code - line "Sheets("PQ AssocCost").ListObjects("PQ_AssocCost").DataBodyRange.Copy"
could this be bacuase the table that its trying to copy is empty? This may be the case from time to time. If that is the reason, whats the work-around? is there an If statement I can add (if the error is because the table is empty)?
Thanks for the help and training! Teach a person to fish!
on this code - line "Sheets("PQ AssocCost").ListObjects("PQ_AssocCost").DataBodyRange.Copy"
could this be bacuase the table that its trying to copy is empty? This may be the case from time to time. If that is the reason, whats the work-around? is there an If statement I can add (if the error is because the table is empty)?
Code:
Sub CreateStep5()
'Associated Costs Step C
'Copy PQ AssocCost Table and Paste in Step5
Application.ScreenUpdating = False
Sheets("PQ AssocCost").ListObjects("PQ_AssocCost").DataBodyRange.Copy
Sheets("Step 5").Range("B16").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
'Copy Selected into Previously Selected so User can see what was Prev Selected
Range("Step_5_Table[Select]").Select
Selection.Copy
Range("Step_5_Table[Previously_Selected]").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Columns("C:W").EntireColumn.AutoFit
Sheets("Step 5").Range("B16").Select
Application.ScreenUpdating = True
End Sub
Thanks for the help and training! Teach a person to fish!