Adding a Clear Field Button to an excel file?

L

Legacy 50109

Guest
Not too familiar with visual basics, and I believe its possible.

I have an excel file that will be used on a constant basis for some basic calculations.

Does anyone know how to add a "Clear Field" button to an excel file?

It would be about 2-3 fields that would require constant data entry and needs to be cleared each time, with the click of a button.

Thanks,
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Sub clear()
Range("D43,D44,D45").Select
Range("D45").Activate
Selection.ClearContents
End Sub
 
Upvote 0
I know I'm kind of new, but it didn't work?

Am I doing something wrong?

I changed the value to correspond with the cells I want cleared, but how to I create the "clear button".

Thanks,
 
Upvote 0
Selects will lead to troubles :eek: ... here's the above macro cleaned up :wink:

Code:
Sub clearV2()
    Range("D43,D44,D45").ClearContents
End Sub

Once you've got the macro running you can create a ShortCut-Key to it by going to Tools..Macro..Macros... and clicking on the "Options" button.
 
Upvote 0

Forum statistics

Threads
1,214,893
Messages
6,122,121
Members
449,066
Latest member
Andyg666

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top