![]() |
Delete cell contents that contain numbers and not formulae ...
Hi,
Using VBA, I'm looking for a way to delete the contents of all cells within a worksheet that contain numbers only and not formulae or text. Is this possible? Many thanks for the help. Rob Keel. |
Delete cell contents that contain numbers and not formulae ...
Code ------------------- For Each cell In Range("A1:A5") 'Range is to be set manually or just "ActiveSheet.Cells" for the whole sheet If Not (cell.HasFormula Or (cell.Value < 0 And cell.Value 9)) Then cell.ClearContents Next cel ------------------- It's simple but works :) Simon ------------------------ Just mentioned that you didn't want to delete text. Have to edit th code then. So don't use it in the meantime. ------------------------ Ok, the If-Statement had to be edited: Code ------------------- If (cell.HasFormula = False) And (IsNumeric(cell.Value)) Then cell.ClearContent ------------------- ; -- moondar ----------------------------------------------------------------------- moondark's Profile: http://www.excelforum.com/member.php...fo&userid=2739 View this thread: http://www.excelforum.com/showthread.php?threadid=46987 |
Delete cell contents that contain numbers and not formulae ...
Dim cell As Range
For Each cell In ActiveSheet.UsedRange If Not cell.HasFormula Then If IsNumeric(cell.Value) Then cell.ClearContents End If End If Next cell -- HTH Bob Phillips "Rob Keel" wrote in message ups.com... Hi, Using VBA, I'm looking for a way to delete the contents of all cells within a worksheet that contain numbers only and not formulae or text. Is this possible? Many thanks for the help. Rob Keel. |
Delete cell contents that contain numbers and not formulae ...
Excellent. Thank you Bob.
Rob. Bob Phillips wrote: Dim cell As Range For Each cell In ActiveSheet.UsedRange If Not cell.HasFormula Then If IsNumeric(cell.Value) Then cell.ClearContents End If End If Next cell -- HTH Bob Phillips "Rob Keel" wrote in message ups.com... Hi, Using VBA, I'm looking for a way to delete the contents of all cells within a worksheet that contain numbers only and not formulae or text. Is this possible? Many thanks for the help. Rob Keel. |
All times are GMT +1. The time now is 07:12 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com