Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Delete Activecell if it is not numeric
HI,
How do I delete the Activecell if it is not numeric? Thanks in Advance FIRSTROUNDKO -- Message posted via http://www.officekb.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Delete Activecell if it is not numeric
Hi,
You don't give too much to go on and in fact what you intend to do sounds very high risk to me, you could inadvertantly end up deleting data you might not want to. Right click your sheet tab, view code and paste this in. Because it is so risky I've limited the functionality to a single cell A1. The commented out line shows you how to use this on a range of cells. Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub 'If Not Intersect(Target, Range("A1:A10")) Is Nothing Then If Target.Address = "$A$1" Then If Not IsNumeric(Target.Value) Then Target.ClearContents End If End Sub Mike "FIRSTROUNDKO via OfficeKB.com" wrote: HI, How do I delete the Activecell if it is not numeric? Thanks in Advance FIRSTROUNDKO -- Message posted via http://www.officekb.com |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Delete Activecell if it is not numeric
With ActiveCell
If Application.IsNumber(.Value) Then 'skip it Else .Delete shift:=xlShiftUp 'or xlshifttoleft 'or '.EntireRow.Delete 'or '.ClearContents 'or '.Clear End If End With I'm not sure what delete means in your case. "FIRSTROUNDKO via OfficeKB.com" wrote: HI, How do I delete the Activecell if it is not numeric? Thanks in Advance FIRSTROUNDKO -- Message posted via http://www.officekb.com -- Dave Peterson |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Delete Activecell if it is not numeric
Dave,
Thanks for a nice easy code Dave Peterson wrote: With ActiveCell If Application.IsNumber(.Value) Then 'skip it Else .Delete shift:=xlShiftUp 'or xlshifttoleft 'or '.EntireRow.Delete 'or '.ClearContents 'or '.Clear End If End With I'm not sure what delete means in your case. HI, [quoted text clipped - 6 lines] -- Message posted via http://www.officekb.com -- Message posted via http://www.officekb.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
TO DELETE ONLY NUMERIC VALUES IN A CHARACTER AND NUMERIC CELL IN | Excel Discussion (Misc queries) | |||
Need Help with ActiveCell.EntireRow.Delete | Excel Discussion (Misc queries) | |||
Need Help with ActiveCell.EntireRow.Delete | Excel Discussion (Misc queries) | |||
Delete first character in ActiveCell | Excel Programming | |||
Delete the row where the activecell is located with VBA | Excel Programming |