Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default More Selecting and Deleting

Dim lastrow As Long, i As Long
Dim cell As Range

lastrow = Cells(Rows.Count, "I").End(xlUp).Row
For i = lastrow To 1 Step -1
Set cell = Cells(i, "I")
If IsNumeric(cell) Then
If cell < 7 Then
cell.Offset(0, -4).Resize(1, 6).Delete shift:=xlToLeft
End If
End If
Next

This formula works great to do the following: If the value in the cell is
less than 7 it will select columns 1 - 6 and delete that row selection then
shift all cells to the right over left into it's place.

I want the "If Cell < 7 Then" to be more like:

If the cell value is anything but 1 or 7 then delete the selection. So
something like If Cell < 1 And betwee 1 & 7 then delete selection. I'm
probably making this way too complicated, and I'm not programming savvy
enough to figure out the line of code. THANKS!!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default More Selecting and Deleting

How about using some logic

If NOT (cell = 1 OR cell = 7) then .......



"bodhisatvaofboogie" wrote:

Dim lastrow As Long, i As Long
Dim cell As Range

lastrow = Cells(Rows.Count, "I").End(xlUp).Row
For i = lastrow To 1 Step -1
Set cell = Cells(i, "I")
If IsNumeric(cell) Then
If cell < 7 Then
cell.Offset(0, -4).Resize(1, 6).Delete shift:=xlToLeft
End If
End If
Next

This formula works great to do the following: If the value in the cell is
less than 7 it will select columns 1 - 6 and delete that row selection then
shift all cells to the right over left into it's place.

I want the "If Cell < 7 Then" to be more like:

If the cell value is anything but 1 or 7 then delete the selection. So
something like If Cell < 1 And betwee 1 & 7 then delete selection. I'm
probably making this way too complicated, and I'm not programming savvy
enough to figure out the line of code. THANKS!!!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default More Selecting and Deleting

If cell < 1 And cell < 7 Then

HTH

Die_Another_Day

bodhisatvaofboogie wrote:
Dim lastrow As Long, i As Long
Dim cell As Range

lastrow = Cells(Rows.Count, "I").End(xlUp).Row
For i = lastrow To 1 Step -1
Set cell = Cells(i, "I")
If IsNumeric(cell) Then
If cell < 7 Then
cell.Offset(0, -4).Resize(1, 6).Delete shift:=xlToLeft
End If
End If
Next

This formula works great to do the following: If the value in the cell is
less than 7 it will select columns 1 - 6 and delete that row selection then
shift all cells to the right over left into it's place.

I want the "If Cell < 7 Then" to be more like:

If the cell value is anything but 1 or 7 then delete the selection. So
something like If Cell < 1 And betwee 1 & 7 then delete selection. I'm
probably making this way too complicated, and I'm not programming savvy
enough to figure out the line of code. THANKS!!!


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
Locating the row that has no values. Selecting that row till the last row after that and deleting it? VB Script for Excel Excel Programming 2 May 25th 06 01:19 PM
Selecting AND Deleting bodhisatvaofboogie Excel Discussion (Misc queries) 11 May 24th 06 01:18 PM
Selecting image on worksheet and deleting.. groundhog1 Excel Programming 7 February 21st 06 11:03 PM
selecting and deleting a row based on a cell value JJ Excel Programming 4 December 1st 04 05:59 PM
Selecting Text and deleting Page andycharger[_30_] Excel Programming 1 May 18th 04 11:04 AM


All times are GMT +1. The time now is 02:27 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"