Delete Column

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
 
G

Gord Dibben

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
 
B

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




- Show quoted text -



The name will be found only in one column. Thanks!
 
G

Gord Dibben

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
 
B

Bernie

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top