Link to home
Start Free TrialLog in
Avatar of Mohammad Alsolaiman
Mohammad AlsolaimanFlag for Saudi Arabia

asked on

Delete Entire Column by column name - using VBA

I need to delete Entire column in Excel sheet using column name.
In my example I need to delete the 3rd column with the name "DateOfBirth", instead of using column number.
User generated imageThe code I'm using right now is:
Sub sbVBS_To_Delete_EntireColumn ()
End Sub

Open in new window

Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

try this:

Sub sbVBS_To_Delete_EntireColumn(columnName As String)
End Sub

Open in new window

to implement:

call sbVBS_To_Delete_EntireColumn("C")

Open in new window

Avatar of Subodh Tiwari (Neeraj)
Subodh Tiwari (Neeraj)
Flag of India image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mohammad Alsolaiman


Thanks Ryan
That's much better than column number, but I would prefer if there is any way to delete it using the name appear in the first row, which in my case is " DateOfBirth" . is it possible to do so?
thanks to all of you
You're welcome!