mercredi 25 janvier 2017

"Wrong number of arguments or invalid property assignment" Error when trying to delete values in cells

the segment of my code is as follows,

If Not Column2 = Empty Then
    Set Rg2 = BalkanSheet.Cells.Find(What:=Column2)
    If Not Rg2 Is Nothing Then
        Column2Width = Rg2.MergeArea.Columns.Count - 1
        StartCol2Column = Rg2.Column
        EndCol2Column = StartCol2Column + Column2Width
    Else
        MsgBox Column2 & " not found in " & BalkanSheet.Name
    End If
    Else
    Worksheets("Graph").Range(Cells(i, 7), Cells(i, 8), Cells(i, 9), Cells(i, 10)).Value = ""
End If

When i try to run it i get an error with the line Worksheets("Graph").Range(Cells(i, 7), Cells(i, 8), Cells(i, 9), Cells(i, 10)).Value = "", saying "Wrong number of arguments or invalid property assignment".

The i value is a variable that is set earlier in the code. What i want the code to do is if the If statement is false (Else) then it will delete the values in the cells specified.

Any ideas?

Aucun commentaire:

Enregistrer un commentaire