ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   how to delete specific values in cells (https://www.excelbanter.com/new-users-excel/200677-how-delete-specific-values-cells.html)

[email protected]

how to delete specific values in cells
 
Hi,
I have a problem with excel 2007. I want to delete some columns which
include some words (like as @xxx.com.au). How to delete those colums
with macro?
Pls let me know. Thanks.

Gary''s Student

how to delete specific values in cells
 
Consider:

Sub col_killer()
Dim r As Range, cel As Range
Dim s As String
s = "
Set r = Nothing

For Each cel In ActiveSheet.UsedRange
If cel.Value = s Then
If r Is Nothing Then
Set r = cel
Else
Set r = Union(r, cel)
End If
End If
Next

If r Is Nothing Then
Else
r.EntireColumn.Delete
End If
End Sub
--
Gary's Student - gsnu2007k


" wrote:

Hi,
I have a problem with excel 2007. I want to delete some columns which
include some words (like as @xxx.com.au). How to delete those colums
with macro?
Pls let me know. Thanks.



All times are GMT +1. The time now is 10:51 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com