Delete Column

  • Thread starter Thread starter Bernie
  • Start date Start date
B

Bernie

In Excel, I need a macro that will delete a column based on a cell
that will contain a name based on an input box.

Thanks,
Bernie
 
Bernie

Will the name be found only in one column or many columns?

If many, which one or more of the many would you like deleted?


Gord Dibben MS Excel MVP
 
Bernie

Will the name be found only in one column or many columns?

If many, which one or more of the many would you like deleted?

Gord Dibben MS Excel MVP




- Show quoted text -



The name will be found only in one column. Thanks!
 
Try this with a fixed column.

Note the lines to make it a selectable column if you wanted.

Public Sub DeleteColOnWord()
Dim coltocheck As Range
Dim thename As String
On Error GoTo endit

Set coltocheck = Range("D:D")
' Set coltocheck = Application.InputBox(Prompt:= _
' "Select A Column", Type:=8)
thename = InputBox("enter a name")
For Each i In coltocheck
If i.Value = thename Then _
i.EntireColumn.Delete
Next i

endit:
End Sub


Gord
 
Try this with a fixed column.

Note the lines to make it a selectable column if you wanted.

Public Sub DeleteColOnWord()
Dim coltocheck As Range
Dim thename As String
On Error GoTo endit

Set coltocheck = Range("D:D")
' Set coltocheck = Application.InputBox(Prompt:= _
' "Select A Column", Type:=8)
thename = InputBox("enter a name")
For Each i In coltocheck
If i.Value = thename Then _
i.EntireColumn.Delete
Next i

endit:
End Sub

Gord




- Show quoted text -

Thank you so much, I modified it to fit my current workbook and it
worked perfectly.

Bernie
 
Back
Top