View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mlawrence Mlawrence is offline
external usenet poster
 
Posts: 1
Default Clear Contents of multiple continuous ranges

Hi all,
I am trying to clear the content of certain cells in my worksheet only if
certain criteria is met. For Example,
If C5=Delete I want the following range cleared (G3:H3,K3:L3, H5:K7,M5:O7
If C12=Delete I want the following range
cleared(G10:H10,K10:M10,H12:K14,M12:O14)
and so on

Dont know if this will help but,
there is some relationship of 6 cells in between one range and the other
(from C5 to C12 there're 6 cells (that I want to remain untouch) from C12 and
C19 there are 6 cells and so on. The same with the range I want to be
cleared
From G3 to G10 there are 6 cells (that I want to reamin untouch)

This is what I have: but is not working (there's no changes on my worksheet)
-----------------------------------------
Dim x As Long
Dim lastrow As Long

Application.ScreenUpdating = False

lastrow = Range("A65536").End(xlUp).Row

For x = 5 To lastrow
If Cells(x, 3) = "Delete" Then
Range("G3:H3, K3:L3, H5:K7,M5:O7, G10:H10, K10:M10, H12:K12,
M12:O12").ClearContents
Application.ScreenUpdating = True
End If
Next x

End Sub