I have a button on my spreadsheet which activates some code, it has worked perfectly for over a year but now for some reason I cannot get it to work.
When I click on the button now I get the message: Run-time error '1004' Method 'Range' of object '_Global' failed.
Apologies if this is a simply query but i do not understand VBA at all, the file is far too large to attach here but here is the relevant code:
Sub UpDateResults()
Dim s As Range, i As Variant, t As Range, w As Range, _
cc As Range, c As Range, w2 As Range, j As Integer, Val As Integer
Val = Sheet3.Range("AG1").Value
Set s = Range("Scores")
Set t = Range("Table")
Set w = t.Cells(1, 1).End(xlToRight).Offset(0, 1) 'first empty week
Set w2 = t.Cells(1, 1).Offset(0, 31).End(xlToRight).Offset(0, Val)
Application.Calculation = xlManual 'turn off calculations
If Sheet4.Range("IV1").Value = 1 Then
For Each cc In s
For j = -1 To 4 Step 5
Set c = cc.Offset(0, j)
i = Application.Match(c.Offset(0, -3), t, 0) 'get player position
If IsError(i) Then
MsgBox "Cannot locate " & c.Offset(0, -3) & " in the table."
Else
w2.Cells(i, 1).Value = c
End If
Next j
Next cc
w2.Range("A1:A" & t.Rows.Count).Replace What:="", Replacement:="DNP", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False
Else
For Each cc In s
For j = -1 To 4 Step 5
Set c = cc.Offset(0, j)
i = Application.Match(c.Offset(0, -3), t, 0) 'get player position
If IsError(i) Then
MsgBox "Cannot locate " & c.Offset(0, -3) & " in the table."
Else
w.Cells(i, 1).Value = c
End If
Next j
Next cc
w.Range("A1:A" & t.Rows.Count).Replace What:="", Replacement:="DNP", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False
End If
'w.Range("A1:A" & t.Rows.Count).Replace What:="", Replacement:="DNP", LookAt:=xlWhole, _
'SearchOrder:=xlByRows, MatchCase:=False
Application.Calculation = xlAutomatic 'turn on calculations
Sheet4.Range("IV1").Value = 0
End Sub
Display More
As usual any help would be greatly appreciated
regards
Billy B