Clear Cell data with condition

azhri

New Member
Joined
Jul 11, 2015
Messages
10
Hi..

I want to clear cells contents from column D to N When the cell in column A is empty for each row, or when I delete the cell from A coloumn
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
I want to delete columns from D to N
ex.
when Cell A5 is empty or I delete the content from A5 the cells from D5 to N5 is deleted

So if A5 is empty, you want to delete the cells D5 to N5? Which way should the cells shift? If you wish to delete the cells and not simply clear them it will require a macro.
 
Upvote 0
If that is the case, try this macro:

Code:
Dim i As Integer
Dim lrow As Long

lrow = Cells.Find(What:="*", after:=Range("A1"), lookat:=xlPart, LookIn:=xlFormulas, searchorder:=xlByRows, searchdirection:=xlPrevious, MatchCase:=False).Row

For i = 1 To lrow
    If IsEmpty(Range("A" & i).Value) = True Then
        Range("D" & i & ":N" & i).ClearContents
    End If
Next
 
Upvote 0
Another option
Code:
Sub ClearRange()
   Dim Rng As Range
   
   For Each Rng In Range("A:A").SpecialCells(xlBlanks).Areas
      Rng.Offset(, 3).Resize(, 11).ClearContents
   Next Rng
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top