ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help Clear Function (https://www.excelbanter.com/excel-programming/326221-help-clear-function.html)

Ed[_26_]

Help Clear Function
 
Hv a Excel file with 3 sheets for calculation of various charges..On each
sheet, most of the cells are protected against changes because of built-in
functions and formulas. A minority of these cells are NOT protected as they
require users' input. Since these sheets are re-used often, is there anyway
to write a VBA string for a button option to clear these entries everytime
Excel starts up? The button should ideally work for each sheet only. Any
help would be appreciated. Thanks in adv.

Ed.




Tom Ogilvy

Help Clear Function
 
Sub Demo()
with Worksheets("Sheet8")
.Range("A2,B9:B15,C12,A13,F1:F10").ClearContents
End with
End Sub

Assign the macro to your button for Sheet8

--
regards,
Tom Ogilvy

"Ed" wrote in message
...
Hv a Excel file with 3 sheets for calculation of various charges..On each
sheet, most of the cells are protected against changes because of built-in
functions and formulas. A minority of these cells are NOT protected as

they
require users' input. Since these sheets are re-used often, is there

anyway
to write a VBA string for a button option to clear these entries everytime
Excel starts up? The button should ideally work for each sheet only. Any
help would be appreciated. Thanks in adv.

Ed.






Bob Phillips[_6_]

Help Clear Function
 
Sub ClearCells()
Dim cell As Range
With ActiveSheet
For Each cell In .UsedRange
If Not cell.Locked Then
cell.ClearContents
End If
Next cell
End With
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Ed" wrote in message
...
Hv a Excel file with 3 sheets for calculation of various charges..On each
sheet, most of the cells are protected against changes because of built-in
functions and formulas. A minority of these cells are NOT protected as

they
require users' input. Since these sheets are re-used often, is there

anyway
to write a VBA string for a button option to clear these entries everytime
Excel starts up? The button should ideally work for each sheet only. Any
help would be appreciated. Thanks in adv.

Ed.







All times are GMT +1. The time now is 08:01 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com