Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Macro to delete rows if they don't begin with "0"

Hi - and thanks for reading this.
I have a macro where I am trying to delete rows that don't begin with "0".
These are text cells (hence the apostrophes). The sample below deletes the
rows if they DO begin with "0" and I can't find out how to make it delete if
they DON'T being with "0". I've searched the group for ages - without
success. I've tried Not Like - but that doesn't work.
Thanks for your help (it's probably easy for you!)

Application.ScreenUpdating = False
For i = 90 To 3 Step -1
If Cells(i, 1).Value Like "0*" Then Rows(i).Delete
Next
Application.ScreenUpdating = True


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Macro to delete rows if they don't begin with "0"

Hi
You could try

If left(Cells(i, 1).Value,1) ="0" Then Rows(i).Delete

regards
Paul


On Feb 25, 12:33*pm, <Andy wrote:
Hi - and thanks for reading this.
I have a macro where I am trying to delete rows that don't begin with "0".
These are text cells (hence the apostrophes). The sample below deletes the
rows if they DO begin with "0" and I can't find out how to make it delete if
they DON'T being with "0". I've searched the group for ages - without
success. I've tried Not Like - but that doesn't work.
Thanks for your help (it's probably easy for you!)

Application.ScreenUpdating = False
* For i = 90 To 3 Step -1
* * If Cells(i, 1).Value Like "0*" Then Rows(i).Delete
* Next
Application.ScreenUpdating = True


  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Macro to delete rows if they don't begin with "0"

Hi - and thanks!

I've modified it to < "0" and that's great!

Cheers.

wrote in message
...
Hi
You could try

If left(Cells(i, 1).Value,1) ="0" Then Rows(i).Delete

regards
Paul


On Feb 25, 12:33 pm, <Andy wrote:
Hi - and thanks for reading this.
I have a macro where I am trying to delete rows that don't begin with "0".
These are text cells (hence the apostrophes). The sample below deletes the
rows if they DO begin with "0" and I can't find out how to make it delete
if
they DON'T being with "0". I've searched the group for ages - without
success. I've tried Not Like - but that doesn't work.
Thanks for your help (it's probably easy for you!)

Application.ScreenUpdating = False
For i = 90 To 3 Step -1
If Cells(i, 1).Value Like "0*" Then Rows(i).Delete
Next
Application.ScreenUpdating = True



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Macro to delete rows if they don't begin with "0"

Andy,

Try this

If Left(Cells(i, 1).Value, 1) = "o" Then Rows(i).Delete

Note this is case sensitive for a non case sensitive version use
If UCase(Left(Cells(i, 1).Value, 1)) = "O" Then Rows(i).Delete

Mike

"Andy" wrote:

Hi - and thanks for reading this.
I have a macro where I am trying to delete rows that don't begin with "0".
These are text cells (hence the apostrophes). The sample below deletes the
rows if they DO begin with "0" and I can't find out how to make it delete if
they DON'T being with "0". I've searched the group for ages - without
success. I've tried Not Like - but that doesn't work.
Thanks for your help (it's probably easy for you!)

Application.ScreenUpdating = False
For i = 90 To 3 Step -1
If Cells(i, 1).Value Like "0*" Then Rows(i).Delete
Next
Application.ScreenUpdating = True



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Macro to delete rows if they don't begin with "0"

On 25 Feb, 13:33, <Andy wrote:
Hi - and thanks for reading this.
I have a macro where I am trying to delete rows that don't begin with "0".
These are text cells (hence the apostrophes). The sample below deletes the
rows if they DO begin with "0" and I can't find out how to make it delete if
they DON'T being with "0". I've searched the group for ages - without
success. I've tried Not Like - but that doesn't work.
Thanks for your help (it's probably easy for you!)

Application.ScreenUpdating = False
* For i = 90 To 3 Step -1
* * If Cells(i, 1).Value Like "0*" Then Rows(i).Delete
* Next
Application.ScreenUpdating = True


Do you really need a macro?

If you don't, then....

1) filter on the data such that the rows you don't want are visible
2) Select the visible rows
3) Delete the rows


Regards


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
delete rows if cell in row contains "a" or "o" or empty bartman1980 Excel Programming 2 November 4th 07 08:20 PM
Look for cell containing "Initial" then if the next cell after equals "Final" then delete both rows. [email protected][_2_] Excel Programming 3 September 28th 07 01:45 PM
Help with a "delete rows" Macro NewUser22 Excel Programming 1 April 20th 07 05:44 PM
Custom Menus & "Begin a Group" option JMMach[_2_] Excel Programming 5 June 12th 05 01:08 PM
Search "Total" in all worksheets and delete rows containing "Total" mk_garg20 Excel Programming 2 July 30th 04 06:42 AM


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