MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Clear cells macro

Posted by Loes on April 25, 2000 6:22 AM

Hello there,

I'm trying to write a Clear-cells macro that (for example) does the following:

- Delete the contents cells A1:A15;
- Deletes the contents of cells C4:C8, D12:D15 and F9:G12;
- Sets the fontcolour in cell C1 to red and sets the fillcolor to yellow;
- Displays the text: Macro execution completed.

So far I've been able to write three macro's for eacht task, but I havn't been able to put it all in 1 macro. Can anyone help me?

Thanks a lo!


Posted by Ivan Moala on April 25, 2000 8:47 PM

Hi Loes
Try something like this;

Sub Clr_ALL()
Dim ClrRg
Dim Rg

Set ClrRg = Union(Range("A1:A15"), Range("C4:C8"), Range("D12:D15"), Range("F9:G12"))
Set Rg = Range("C1")


With Rg
.Font.ColorIndex = 3
.Interior.ColorIndex = 6
End With

MsgBox "Range has been cleared", vbInformation
End Sub

Posted by Loes on April 27, 2000 3:40 AM

Works just fine!

Thanks a lot Ivan.