Archive of Mr Excel Message Board

Back to Excel VBA archive index
Back to archive home

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!


Check out our Excel VBA Resources

Re: Clear cells macro

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

Re: Clear cells macro

Posted by Loes on April 27, 2000 3:40 AM
Works just fine!

Thanks a lot Ivan.



This archive is from the original message board at
All contents © 1998-2004
Visit our online store to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.