Solved

Excel VBA - can't delete proper row question

Posted on 2003-12-09
3
222 Views
Last Modified: 2010-05-01
What i'm trying to do is run through a bunch of rows and for each instance of the word "Mike", I want to delete that row. Problem is, I can't figure out which row i'm on. I know i'm only missing a line or two and some assistance would be greatly appreciated.

Sub testing()

For Each i In Worksheets("Sheet1").Range("A1:A10").Cells
If i.Value = "Mike" Then
' WHAT ROW AM I ON?????
' HOW DO I PASS IT SO I CAN DELETE IT?
ActiveCell.EntireRow.Delete
End If
Next


End Sub

0
Comment
Question by:KABOOM
3 Comments
 
LVL 9

Accepted Solution

by:
malharone earned 50 total points
ID: 9908477
i did nt have an editor ... hope my syntax is right

dim x as integer=1  '<-- i think excel still uses 1 based indexing
dim MAX_SEARCH_ITEMS as integer=1000
While x<MAX_SEARCH_ITEMS
  if worksheets("sheet1").range("A" & x).value ="MIKE" then
       activecell.entirerow.delete
  else
       x+=1
  endif
Wend


hope this helps
0
 
LVL 27

Expert Comment

by:planocz
ID: 10235428
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
No response from KABOOM from 12/09/2003 comment
Award points to malharone is recommend.
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

planocz
EE Cleanup Volunteer
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now