Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Conditionally Delete Cells From Named Range

Thanks Tom

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditionally Formatting Cells based on Values in a Range (2007) sreid64 Excel Worksheet Functions 3 August 26th 09 08:15 PM
Named range/cell, sort & delete nc Excel Discussion (Misc queries) 1 July 11th 09 12:55 AM
Delete Hidden Named Range Scott Excel Discussion (Misc queries) 3 July 24th 08 09:40 PM
How do I delete the name for a named range i no longer require? Chris Mitchell Excel Worksheet Functions 2 June 23rd 07 12:38 PM
inserting a named range into new cells based on a named cell Peter S. Excel Discussion (Misc queries) 1 June 4th 06 03:53 AM


All times are GMT +1. The time now is 05:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"