I am searching for a name in one row in excel. I would like to delete all columns before that name till a specific column E.g. my Name is in column 10 and I want to delete all from column 2 to column 9 so that column 10 with my name will be then at position of column 2.
Sub delete_cells()
Dim rg As Range
Set rg = ActiveSheet.Rows(2).Find(What:="Name", LookIn:=xlValues, LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False)
If Not rg Is Nothing Then
If rg.Column > 1 Then ActiveSheet.Columns("4:" & rg.Column - 3).Delete
Else
MsgBox "Something
End If
End Sub
I get an run time error. Why?
EDIT explanation:
I need to search for "Name" in row 2 and take all values from Column I, J, K etc. to Column E. So I need columns E to H to be deleted and move columns I, J etc. only for the given row. There should no columns of other rows being deleted.

Then ActiveSheet.Columns("4:" & rg.Column - 3).Delete. It gives an application or object defined error.