Macro?

  • Thread starter Thread starter John Persico
  • Start date Start date
J

John Persico

I have a spreadsheet with 25000 rows.
This is what I want to do:
If ColumnJ has the text "To Be Categorized" then I want to delete that
entire row from the spreadsheet.

Make sense?

--
 
sub deleterowiftext()
dim i as long
for i=cells(rows.count,"J").end(xlup).row to 1 step -1
if ucase(cells(i,"j"))="TO BE CATEGORIZED" then rows(i).delete
next i
end sub
 
That worked well.

I'm not real familiar with VB. I have some questions.
First of all, I ran the VB and then when I tried to save the file it said I
have to save it with a file type that supported macros.
Can a script only be saved within one file, or can it be saved so that
whenever I open Excel I have it available to me?
And, I'm guessing the only way to run a script is to click "Run," right?
Will scripts run automatically? I only want this script to run when I want
it to.

The situation is that the file I'm going to be running this script will be
overwritten repeatedly. So, I'm guessing that that will get rid of the VB
code, which is why I'm wondering if the code can be saved "universally" in
Excel.

Hope this makes sense.


--


Don Guillett said:
sub deleterowiftext()
dim i as long
for i=cells(rows.count,"J").end(xlup).row to 1 step -1
if ucase(cells(i,"j"))="TO BE CATEGORIZED" then rows(i).delete
next i
end sub
 
You must have xl2007 and put the code in an .xlsX file. Macros cannot be
saved in an .xlsX file. Save as .xlsM


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
John Persico said:
That worked well.

I'm not real familiar with VB. I have some questions.
First of all, I ran the VB and then when I tried to save the file it said
I have to save it with a file type that supported macros.
Can a script only be saved within one file, or can it be saved so that
whenever I open Excel I have it available to me?
And, I'm guessing the only way to run a script is to click "Run," right?
Will scripts run automatically? I only want this script to run when I
want it to.

The situation is that the file I'm going to be running this script will be
overwritten repeatedly. So, I'm guessing that that will get rid of the VB
code, which is why I'm wondering if the code can be saved "universally" in
Excel.

Hope this makes sense.
 
Back
Top