How to delete rows that start with a letter rather than a number

chris2013

New Member
Joined
Feb 28, 2013
Messages
2
Hi I have a sheet that has letters and numbers in the "A" column but I want to keep only those that start with a number and delete all those that start with a letter here is the code that I adapted from another post :


count = 0
For i = 7 To 151
Select Case Val(Left(Range("A" & i).value, 1))
Case 3
'do nothing
Case Else
Rows(i).Delete
count = count + 1
End Select
Next i




It leaves several columns that start with something other then a 3 at the bottom.

Help anyone? :confused:
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Welcome to the board..

When deleting rows or columns, you have to go backwards (top to bottom / right to left)

Example, if you get to say row 10, and it meets the criteria and is deleted.
So what was in row 11 is now in row 10.
And what was in row 12 is now in row 11
Your loop then moves on to test row 11.
So whatever was in row 11 essentially got skipped.


Try changing
For i = 7 To 151
to
For i = 151 To 7 Step -1
 
Upvote 0

Forum statistics

Threads
1,217,332
Messages
6,135,946
Members
449,974
Latest member
riffburn

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top