View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default VB for an entire worksheet

Hi M,

Why not delete only the non-formula cells?


Dim rng As Range
Set rng = Range("f16:f40")

On Error Resume Next
rng.SpecialCells(xlCellTypeConstants).ClearContent s
On Error GoTo 0


---
Regards,
Norman



"msals22" wrote in
message ...

I have a few command buttons to reset some cells in my worksheet.
However, I cannot figure out how to keep the conditional statements in
the cell after I've cleared the entries in the cells. I am trying to
add some VB to the worksheet to do the conditionals for me. I.e., if
E16 = Yes, F16 = Enter Value. I've been trying to use some scripts
such as:

ActiveCell.FormulaR1C1 = "=IF(RC[-1]=""Yes"",""Enter Value"","""")"
Range("F16").Select

I am trying to add this code he
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

When I think I've figured out the logic I get some continuous looping
when I try to clear the contents of the cell with the command button.
An example of the command button code is:

Range("f16:f40").Select
Selection.ClearContents

Thanks for your help.


--
msals22
------------------------------------------------------------------------
msals22's Profile:
http://www.excelforum.com/member.php...o&userid=30908
View this thread: http://www.excelforum.com/showthread...hreadid=549034