Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
PBezucha, thanks for your help !!
SS "PBezucha" wrote: Sorry for a mistake in the 3rd row from the end: Option Explicit Sub DeleteColumsWithKeyword() ' Deletes entire columns if they in the s e l e c t e d range contain Keyword Dim Keyword As String, DefaultKeyword As String Dim S As Range, R As Range, I As Long, J As Long, N As Long Const Title As String = "Deleting all columns with Keyword" Set S = Selection DefaultKeyword = "Delete" Keyword = InputBox("Keyword", Title, DefaultKeyword) If Keyword = "" Then Exit Sub N = S.Columns.Count For I = N To 1 Step -1 Set R = S.Columns(I) J = 0 On Error Resume Next J = WorksheetFunction.Match(Keyword, R, 0) If J 0 Then S.Columns(I).EntireColumn.Delete Next I End Sub -- Petr Bezucha "PBezucha" wrote: One of many ways: Option Explicit Sub DeleteColumsWithKeyword() ' Deletes entire columns if they in the s e l e c t e d range contain Keyword Dim Keyword As String, DefaultKeyword As String Dim S As Range, R As Range, I As Long, J As Long, N As Long Const Title As String = "Deleting all columns with Keyword" Set S = Selection DefaultKeyword = "Delete" Keyword = InputBox("Keyword", Title, DefaultKeyword) If Keyword = "" Then Exit Sub N = S.Columns.Count For I = N To 1 Step -1 Set R = S.Columns(I) J = 0 On Error Resume Next J = WorksheetFunction.Match(Keyword, R, 0) If J 0 Then S.Columns(I).Delete Next I End Sub Regards -- Petr Bezucha "SANDIND" wrote: Hi All, I wanna help writing a Macro that can delete the whole Column if that column has anywhere any specific word/value for eg ."Delete". I want to delete all such Columns in the sheet which contain anywhere "delete". Please help me on this . SS |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
delete a cell if it contains specific word | Excel Discussion (Misc queries) | |||
delete cell that doesn't contain a specific word | Excel Discussion (Misc queries) | |||
Find a specific word in a column | Excel Programming | |||
Finding specific word in column | Excel Worksheet Functions | |||
delete row contains specific word in an macro | Excel Discussion (Misc queries) |