View Single Post
  #3   Report Post  
Peter Rooney
 
Posts: n/a
Default

Hi, Duca,
Be careful when recording your keystrokes, as the recorder will record you
clearing (for example) A1:D20 - say you inserted a new row between rows 2 and
3 - your overall data range would be A1:D21, but your macro would only clear
down to row 20.

A better way is to give a range name to the range of cells you want to work
with, by highlighting the range and using Insert Name Define from the menu.

If you then subsequently insert or delete rows or columns within your named
range, the name will refer to the modified range. You can then use something
like

Sub ClearMyDataRange
Range("MyDataRange").clearcontents
end sub

where MyDataRange is the name you gave to the range.

To attach this to a button, add the "button" tool from the "Forms" category
and use it to draw buttons in your worksheet. When you draw the button, you
will be prompted to specify the macro you want the button to run.

You can change the macro that is attached to a button by right clicking it,
then clicking "Assign Macro" to choose the macro you want to attach.

If you need any help in where to create your macro, please come back!

Hope this helps

Pete


"Ducatisto" wrote:


Firstly hi all,

I am a complete noob when it comes to excel and am just starting to
enjoy the power it offers. I have created an excel file for work that
needs daily information inputted to calculate manpower hours to
complete the daily tasks and at the end of the day needs to be cleared
of that particular days information and the next days inputted. The
task itself is not too particularly time consuming but I would like to
know if there is way that with the aid of a "button" it would clear all
the relevant information instead of manually deleting it.

Duca


--
Ducatisto
------------------------------------------------------------------------
Ducatisto's Profile: http://www.excelforum.com/member.php...o&userid=26976
View this thread: http://www.excelforum.com/showthread...hreadid=401879