Runtime Error '1004': Object's 'Range' method of 'Global_ failed'

I have a problem with excel, with a form that generates a reference number. But when I try to create a reference number. he has an error message:

Runtime Error '1004': Failed to execute the 'Range' method of object'_Global '

When I click on the Debug button, it shows the code as shown below:

It highlights an error on the 4th line of code

Sub clearTemplate()
    ' Clear Template Content
    Range(inputTemplateHeader) = NO_ENTRY
    Range(inputTemplateContent) = NO_ENTRY     - (highlighted error)
End Sub

Sub clearRefNo()
    ' Clear cell G2 reference number
    Range(cellRefNo) = NO_ENTRY

    ' Open "Report_ref_no.xls"
    If Not (IsFileOpen) Then Workbooks.Open filename:=ThisWorkbook.Path & "\" & FACCESS

    ' Activate "Report_ref_no.xls"
    Windows(FACCESS).Activate

    ' Access column D
    Range(cellFirstRefNo).Select
    Selection.End(xlDown).Select

    If refNo = Cells(ActiveCell.Row, ActiveCell.Column - 1).Value Then
        ' Log Development Code column
        Cells(ActiveCell.Row, ActiveCell.Column) = NO_ENTRY

        ' Log Issuer column
        Cells(ActiveCell.Row, ActiveCell.Column + 1).Value = NO_ENTRY

        ' Log Date column
        Cells(ActiveCell.Row, ActiveCell.Column + 2).Value = NO_ENTRY
    End If

    ' Save & Close workbook
    ActiveWindow.Close True
End Sub

Can someone help me with this problem? I donโ€™t know what went wrong?

+5
source share
1 answer

Range , , , . "_Global", , , , .

, Range Activesheet. , .

inputTemplateContent - , , , . RefersTo , , Activesheet, .

- , .

With ThisWorkbook.Worksheets("Template")
    .Range(inputTemplateHeader).Value = NO_ENTRY
    .Range(inputTemplateContent).Value = NO_ENTRY
End With

.

+21

All Articles