Error Changing a range of cells withing the same row

23 Views Asked by At

I am currently trying to change a range of cells to add at the start and at the end, words from other cells within the same row for each of them.

I've made this code below but everytime I turn the macro on, I get the error: 424 asking that an object is required. I do not know what to modify to fix this.

Sub Button2_click()

Application.EnableEvents = False
 
    On Error GoTo ENABLE_EVENTS 'if any error occurs after this line events get enabled.'

If Button2.Value = True Then Range("F50,F167", "G50,G167").Interior.ColorIndex = 0 And Range("F50,F167", "G50,G167").Value = Cells(Target.Row, 13).Value & "- " & Target.Value & "Fault [" & Cells(Target.Row, 9).Value & "]"

Exit Sub

ENABLE_EVENTS:
    Application.EnableEvents = True
    If Err.Number <> 0 Then
         Msg = "Error # " & Str(Err.Number) & " was generated by " _
         & Err.Source & Chr(13) & "Error Line: " & Erl & Chr(13) & Err.Description
       MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
    End If
End Sub
0

There are 0 best solutions below