#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Quirky Code

This code kinda works for me. There is something off about it though.

Dim lastrow As Long, o 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 Not (cell = 1 Or cell = 7 Or cell = D) Then
cell.Offset(0, -4).Resize(1, 6).Delete Shift:=xlToLeft
End If
End If
Next

It is intended to do the following:
Select Column I. If there is a 1, 7, or D in that column, then leave
it. If there is anything else in the column then it is to select Columns E
through J within that row only and delete that part of the row, then shift
everything from the right over into its place.

Now I have the formula repreating 5 times or so to clean up the data, it
works for the most part, BUT there are a small handful or rows it doesn't
work for. It's not the same rows every time either, so I'm not sure what is
wrong with it. Some rows it will just keep deleting, regardless of the
numbers/letters in the cell. What am I doing wrong? Thanks!!!!
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Quirky Code


The first thing I noticed was

If IsNumeric(cell) Then .... If Not (cell = 1 Or cell = 7 Or cell = D)
Then

If a cell is numeric it can't contain a D

The second thing was

cell = D I think you mean cell = "D"

So maybe this is what your lokking for

Dim lastrow As Long, o As Long
Dim sCell As String

lastrow = Cells(Rows.Count, "I").End(xlUp).Row
For i = lastrow To 1 Step -1
sCell = Trim(Cells(i, "I").Value)
If Not (sCell = "1" Or sCell = "7" Or sCell = "D") Then
cell.Offset(0, -4).Resize(1, 6).Delete Shift:=xlToLeft
End If
Next


--
Kaak
------------------------------------------------------------------------
Kaak's Profile: http://www.excelforum.com/member.php...fo&userid=7513
View this thread: http://www.excelforum.com/showthread...hreadid=555526

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
Formula is being quirky Pierre Excel Worksheet Functions 10 July 24th 07 05:35 AM
SUMPRODUCT Formula quirky.... j razz Excel Discussion (Misc queries) 5 March 28th 07 11:36 PM
quirky array not working BorisS Excel Worksheet Functions 3 February 1st 06 12:47 PM
SUMPRODUCT Acting Quirky RichK Excel Worksheet Functions 2 September 19th 05 08:15 PM
Quirky Button nbs Excel Programming 0 September 2nd 04 07:27 PM


All times are GMT +1. The time now is 07:21 PM.

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

About Us

"It's about Microsoft Excel"