Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditionally Delete Cells From Named Range
I have a 1-D named range "MYRANGE" in a column
I'd like to loop through this range, comparing each of the values in this range to a specific value. If the values are not the same, I want to delete that cell from the named range and then move the other cells up. Here's what I have so far: Set rMyRange = Range("MYRANGE") testvalue = "100" rMyRange.Select For Each cell in Selection If left(Cstr(cell.value),3) < testvalue Then ???? Select that cell ???? Selection.Delete Shift:=xlUp End If Next cell Thanks in advance... |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditionally Delete Cells From Named Range
Dim rng as Range, rMyRange as Range
Dim testValue as String, cell as Range Set rMyRange = Range("MYRANGE") testvalue = "100" rMyRange.Select For Each cell in Selection If left(Cstr(cell.value),3) < testvalue Then if rng is nothing then set rng = cell else set rng = union(rng,cell) end if End If Next cell if not rng is nothing then rng.Delete Shift:=xlshiftUp End if -- Regards, Tom Ogilvy " wrote in message oups.com... I have a 1-D named range "MYRANGE" in a column I'd like to loop through this range, comparing each of the values in this range to a specific value. If the values are not the same, I want to delete that cell from the named range and then move the other cells up. Here's what I have so far: Set rMyRange = Range("MYRANGE") testvalue = "100" rMyRange.Select For Each cell in Selection If left(Cstr(cell.value),3) < testvalue Then ???? Select that cell ???? Selection.Delete Shift:=xlUp End If Next cell Thanks in advance... |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Conditionally Delete Cells From Named Range
Thanks Tom
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Conditionally Formatting Cells based on Values in a Range (2007) | Excel Worksheet Functions | |||
Named range/cell, sort & delete | Excel Discussion (Misc queries) | |||
Delete Hidden Named Range | Excel Discussion (Misc queries) | |||
How do I delete the name for a named range i no longer require? | Excel Worksheet Functions | |||
inserting a named range into new cells based on a named cell | Excel Discussion (Misc queries) |