A Microsoft Excel forum. ExcelBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ExcelBanter forum » Excel Newsgroups » Excel Discussion (Misc queries)
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Create a button to Clear Cells



 
 
Thread Tools Display Modes
  #1  
Old May 15th 05, 08:07 PM
tamato43
external usenet poster
 
Posts: n/a
Default Create a button to Clear Cells

Hello,

Can anyone help me set up a button and macro to clear cells where data is
entered.

Lets say, I'm looking to clear Cells A1,B1,C1 and A3, B3, C3.

Remember I would still need a button that would then prompt the Macro.
Ads
  #2  
Old May 15th 05, 09:07 PM
Naz
external usenet poster
 
Posts: n/a
Default

1) Record yourself clearing the cells, as follows
Tools
Macro
Record New Macro
Select the cells
Press delete
Stop recording the macro.

2) Create button as follows
View
Toolbars
Form
From the forms bar select the button icon
Drag out a rectangular button
Once you have dragged it out a pop up will appear asking you to assign
a macro.
Select the macro you recorded in step 1)

Finished.
Any probs. Post back


--

_______________________
Naz,
London


"tamato43" wrote:

> Hello,
>
> Can anyone help me set up a button and macro to clear cells where data is
> entered.
>
> Lets say, I'm looking to clear Cells A1,B1,C1 and A3, B3, C3.
>
> Remember I would still need a button that would then prompt the Macro.

  #4  
Old May 16th 05, 02:09 AM
David McRitchie
external usenet poster
 
Posts: n/a
Default

The newsgroup for macros is excel.programming
Sorry didn't look very carefully, as I see that question was
answered; however, this is a bit different.

If those are the ONLY cells you want to clear, then i presume this is only
for one worksheet. So you could create a shape on the worksheet
itself and assign the macro to it by right-clicking on the shape.

Here is a macro that is invoked by a double click event on the
worksheet. Install to the worksheet by right click on sheet tab, view code.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Range("A1,B1,C1 , A3, B3, C3").ClearContents
End Sub

If you want a macro to assign to a shape or to a button

Sub Clear_a1b1c1a3b3c3()
Range("A1,B1,C1 , A3, B3, C3").ClearContents
End Sub

to create a shape or a toolbutton see
http://www.mvps.org/dmcritchie/excel/toolbars.htm

If you want something along the lines of removing constants from a selection

on error resume next
Selection.SpecialCells(xlConstants).ClearContents
on error goto 0

---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"tamato43" > wrote in message ...
> Hello,
>
> Can anyone help me set up a button and macro to clear cells where data is
> entered.
>
> Lets say, I'm looking to clear Cells A1,B1,C1 and A3, B3, C3.
>
> Remember I would still need a button that would then prompt the Macro.




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Clear cell contents with a button KFC / A&W Boy Excel Worksheet Functions 1 March 7th 05 09:39 AM
Need to create a SUM for data in a row of cells containing IF fun. Banana Excel Discussion (Misc queries) 1 February 23rd 05 12:37 PM
To safety merge cells without data destroyed, and smart unmerge! Kevin Excel Discussion (Misc queries) 0 December 30th 04 07:17 AM
Heps to design Locked/Unlocked cells in protected worksheet Kevin Excel Discussion (Misc queries) 0 December 30th 04 07:09 AM
how do i reference cells to create a chart? Nick M Charts and Charting in Excel 1 December 15th 04 03:50 AM


All times are GMT +1. The time now is 10:40 PM.


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