Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

'Object'_Global'Failed error code

0

Hello,

I have been using this macro for a couple of moths now, and for some reason on this particular workbook I'm now getting this message. 

I have 3 identical workbooks with the same macro layout and it works on 2 out of the 3, I don't have enough knowledge to know why this one all of a sudden broke.

Sub Davenport_Student_Services()

CopyToPage "Data"

CopyToPage "Fin. Affairs"

MsgBox ("Submitted")

ActiveSheet.PrintOut

End Sub

Function CopyToPage(ws_output As String)

next_row = Sheets(ws_output).Range("A" & Rows.Count).End(xlUp).Offset(1).Row

Sheets(ws_output).Cells(next_row, 1).Value = Range("campus").Value

Sheets(ws_output).Cells(next_row, 2).Value = Range("date_paid").Value

Sheets(ws_output).Cells(next_row, 3).Value = Range("type").Value

Sheets(ws_output).Cells(next_row, 4).Value = Range("amount").Value

Sheets(ws_output).Cells(next_row, 5).Value = Range("payee").Value

Sheets(ws_output).Cells(next_row, 6).Value = Range("payment_for").Value

Sheets(ws_output).Cells(next_row, 7).Value = Range("GL_Number").Value

Sheets(ws_output).Cells(next_row, 8).Value = Range("Notes").Value

End Function

I have put the two commands that are broken in bold. Below is a screenshot of the worksheet it's reporting to.

I have also included the file for more information.

Answer
Discuss

Answers

0
Selected Answer

Morgans

The problem is that somehow you've deleted the named ranges in this file (perhaps by deleting those cells and re-writing them) - if you look at the file in your question and go ribbon Formulas/ Name Manager, you'll see the definitions for Payee and Payment for (referred to in the failed lines in bold in your question above) have =Entry!#REF!.

In the revised file attached, I corrected those respectively to read:

=Entry!$C$19

=Entry!$C$21
Your macro should work now.

Have a good weekend!

Discuss


Answer the Question

You must create an account to use the forum. Create an Account or Login