VBA - Delete rows in a column if value starts with "A"

MrManBoy

New Member
Joined
May 28, 2014
Messages
37
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
  3. Web
Gday All :)

I am hoping if anyone could kindly please assist.

Trying to achieve: VBA to delete all rows in a specific column i.e "A", where the value begins with ","

Example Data:

Column A
Bloggs, Joe
Doe, John
, Sam
, Matt

<tbody>
</tbody>









Hopefully that does make sense, if not let me know what further info is required.

Thank you :biggrin:
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Hey Steve - Thanks for the reply.

Reason for using VBA is to make this part of a group of automated tasks not for myself (I'm just the one tasked with outting this togeher, God knows why).

:eek:
 
Upvote 0
One-way...

Rich (BB code):
Sub xxx()
    Dim LstRw As Long, i As Long
    Application.ScreenUpdating = False
    LstRw = Range("A" & Rows.Count).End(xlUp).Row
    
    For i = LstRw To 1 Step -1
        If Left(Cells(i, 1), 1) = "," Then Cells(i, 1).EntireRow.Delete
    Next
    
    Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0
Solution
Another way,

Code:
Sub Delete_Row()
On Error Resume Next
With Range("A1:A" & Range("A" & Rows.Count).End(xlUp).Row)
    .Replace ",*", "#N/A", xlWhole
    .SpecialCells(xlCellTypeConstants, xlErrors).EntireRow.Delete
End With
End Sub
 
Upvote 0
Mark858 & VDS1 - Thank you both for your assistance, both codes work like a charm!

Really appreciate the help!
(y)
 
Upvote 0

Forum statistics

Threads
1,215,212
Messages
6,123,651
Members
449,111
Latest member
ghennedy

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