As you haven't stated which cells or range...etc this is the best i can do for youCode:Sub Clr_Cells() With ActiveSheet.UsedRange.SpecialCells(xlCellTypeConstants) If .HasFormula Then Else .ClearContents End If End With End Sub
As you haven't stated which cells or range...etc this is the best i can do for youCode:Sub Clr_Cells() With ActiveSheet.UsedRange.SpecialCells(xlCellTypeConstants) If .HasFormula Then Else .ClearContents End If End With End Sub
Kind regards,
Simon Lloyd
hi please assume
the range from f22:r33 has formulas in it and i need to clear only the cells from h22 to r 33
i am not familiar withthe macro code
so kindly let me know how can i clear the contents within this range which has formulas too
thanks i appreciate your help
So you want to clear everything in your stated range including formula?
Kind regards,
Simon Lloyd
Simon may be i did not explain properly
the data range starts from F22: R33
and i need to clear the whole data range i.e from F22:R33 when ever i press the button1
without clearing the formulas in it but only the contents
so i have another button2 to bring data which is working perfectly fine
thanks
Try this:
Code:Sub Clr_Cells() With ActiveSheet.Range("H22:R33").SpecialCells(xlCellTypeConstants) If .HasFormula Then Else .ClearContents End If End With End Sub
Kind regards,
Simon Lloyd
one of two things, either the range you are clearing does not have any formula or as you have shown me the line as above it has a space that shouldn't be there between Ty and pe this should read type
Kind regards,
Simon Lloyd
Please supply a sample file with the code in place so i can see how you used it, there isn't any code in that workbook!
Kind regards,
Simon Lloyd
Bookmarks