I am working off of this thread mrexcel, but am having trouble with it. I am using excel for mac 2011
Two things:
1. First is that when I run this, it highlights the ".Cells(1, i).EntireColumn.Delete" and says "Runtime errorr '1004': Delete method of Range class failed."
2. Where I have "BASEMENT_SF," I would prefer it to be non specific and find all cases of "_SF" that occur in row 1, and possibly anywhere it has the case of "_SF" or "_MF", or others, each of which would be in different cells, but still in the first row.
Thank you
Two things:
1. First is that when I run this, it highlights the ".Cells(1, i).EntireColumn.Delete" and says "Runtime errorr '1004': Delete method of Range class failed."
2. Where I have "BASEMENT_SF," I would prefer it to be non specific and find all cases of "_SF" that occur in row 1, and possibly anywhere it has the case of "_SF" or "_MF", or others, each of which would be in different cells, but still in the first row.
VBA Code:
Sub DelSF()
Dim i As Long, lc As Long
'Assumes header is in row 1
With Sheets("Export")
lc = .Cells(1, Columns.Count).End(xlToLeft).Column
For i = lc To 1 Step -1
If InStr(.Cells(1, i), "BASEMENT_SF") > 0 Then
.Cells(1, i).EntireColumn.Delete
End If
Next i
End With
End Sub
Thank you