PDA

View Full Version : Solved: Deleting multiple values within range of rows



starsky
10-20-2009, 08:50 AM
Hi,

I need to cleanse a range of data within columns L:R of certain text values. The code below does the job with two of those values, I was wondering what the most efficient way would be to complete this task with all half dozen plus values that will need to be deleted. I was thinking Select Case somehow?

Thanks.

Sub DelALML()

Dim Cl As Range
Dim LR As Range

Set LR = Range("L:R")
Application.ScreenUpdating = False

For Each Cl In LR.Cells

If Cl.Value = "Annual Leave (AL)" Or Cl.Value = "Maternity Leave (ML)" Then
Cl.ClearContents
End If

Next Cl
Application.ScreenUpdating = True

End Sub

Bob Phillips
10-20-2009, 09:15 AM
Sub DelALML()

Dim Cl As Range
Dim LR As Range

Set LR = Range("L:R")
Application.ScreenUpdating = False

For Each Cl In LR.Cells

If Not Iserror(Application.Match(Cl.Value, Array("Annual Leave (AL)", "Maternity Leave (ML)"), 0)) Then
Cl.ClearContents
End If

Next Cl
Application.ScreenUpdating = True

End Sub

starsky
10-20-2009, 09:25 AM
You really are a distinguised lord of vba. Thanks for your help today xld.