View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Rick Rothstein Rick Rothstein is offline
external usenet poster
 
Posts: 5,934
Default help creating a button

As others have mentioned, ClearContents is the method you need to use. I
thought you might be interested in knowing that you can combine those two
statements into a single statement...

Sub Button1_Click()
Range("A1:D10,A12:D15").ClearContents
End Sub

Note that each disjointed range reference is separated by a comma and that
the entire reference is enclosed within the same set of parentheses.

--
Rick (MVP - Excel)


"Raz" wrote in message
...
Sub Button1_Click()
Range("A1:D10").Clear
Range("A12:D15").Clear
End Sub

I am using a button with this code above to reset those cells to blank
(deleting prevoius data). But it is deleting all the formatting also.
What do I need to change or add to the code above to clear the text and
numbers keeping all the formatting as it is.

Also should I use a Form control button or ActiveX control button ?