Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
RAZ RAZ is offline
external usenet poster
 
Posts: 120
Default help creating a button

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 ?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,071
Default help creating a button

Change Clear to ClearContents. HTH Otto
"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 ?



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default help creating a button

..clearcontents

And the choice of buttons is up to you. I like to use the controls from the
Forms toolbar. I find them easier to work with.

And if I have lots of them in the worksheet/workbook, I think they behave better
than the controls from the control toolbox toolbar.

Raz wrote:

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 ?


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
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 ?


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
RAZ RAZ is offline
external usenet poster
 
Posts: 120
Default help creating a button

thanks

"Rick Rothstein" wrote:

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 ?





  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,934
Default help creating a button

You are welcome. I just want to note one thing... I made a misstatement in
my original post... when I said "...and that the entire reference is
enclosed within the same set of parentheses" (which is true, but also
somewhat obvious), what I meant to say was "...and that the entire reference
is enclosed within the same set of quote marks" (that is, do NOT put each
disjointed range within its own quote marks).

--
Rick (MVP - Excel)


"Raz" wrote in message
...
thanks

"Rick Rothstein" wrote:

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 ?




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a button... Markv Excel Discussion (Misc queries) 8 June 20th 08 03:32 PM
creating a button JonathanW Excel Discussion (Misc queries) 2 March 20th 07 11:12 PM
Creating a Print Button william4444 New Users to Excel 3 June 22nd 06 07:33 AM
creating a reset button 1vagrowr Excel Discussion (Misc queries) 1 December 17th 05 01:06 PM
Creating button as cell jpizzle Excel Discussion (Misc queries) 1 June 1st 05 01:22 PM


All times are GMT +1. The time now is 01:19 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"