Macro to delete all rows where column A is actually blank or "", on specified sheets

jenmwentworth

New Member
Joined
Mar 1, 2022
Messages
5
Office Version
  1. 365
Platform
  1. Windows
I have a workbook that I need to be able to delete and add names to and resort when necessary. The idea is we would delete and add the names on the "Personal Entry" tab only and get the data to flow to the other tabs. The first step I am trying to do is deleting a name on the "Personal Entry", and then running a macro to delete the rows on the other tabs, of the specified sheets, where column A no longer has a name in it.

I was using a delete macro and it works on my "Personal Entry" tab, but my problem is it is all formulas that make the data flow to the other tabs, so it is not identifying the column A as blank in the other sheets, because there is a formula in it. Please how do I fix this?

Rich (BB code):
Sub DeleteBlankRows()

'Delete Blank Rows For Terminated Employees

'Turn off Screen Updating
Application.ScreenUpdating = False

' Defines variable
Dim ws As Worksheet
Dim lastRow As Long 'This is the last row so code knows where to start

' Defines variable nSheets as the sheets you want to ignore
nSheets = Array("Bogey", "Data Imported")

'Defines variable lastRow as last row of Column A
lastRow = Cells(Rows.Count, 1).End(xlUp).Row

' For each sheet in the active workbook
For Each ws In ActiveWorkbook.Worksheets

    ' If the sheet name is not in the list nSheets then...
    If Not IsNumeric(Application.Match(ws.Name, nSheets, 0)) Then
    
        'Deletes Rows where Column A is empty
       On Error Resume Next
            With ws.Range("A3:A1" & lastRow)
                .Value = .Value
                .SpecialCells(xlCellTypeBlanks).EntireRow.Delete
            End With
    End If

' Check next sheet
Next ws
        
'Turn on Screen Updating
Application.ScreenUpdating = True

End Sub

Commission Worksheet-Kitchen-sort testing recovered 3.xlsm
ABCDEFGHIJKLMNO
1Sales Person Full NameCommission RateBonus Comm. RateBonus Active Amount
2
3BH - Bridgette Henry0.03750.05300000
4CNR - Crystal Rubis0.03750.05300000
5JEG - James Gillhooley0.03750.05300000
6SLB - Seana Brown0.03750.05300000
7TRACI - Traci Ritchey0.03750.05300000
8
9
10
Personal Entry


Commission Worksheet-Kitchen-sort testing recovered 3.xlsm
ABCDEFGHIKLMNOPQRSTUVWX
1SalespersonTotal January Net Sales $$ (Reported Sales + Sales Adjustments)Sales AdjustmentsReported January SalesGross Margin %%Net Margin %%Commission $$'s (Total Sales * Rate)Bonus markers (Total Sales Lookup)Commission Bonus $$ (Total Sales Lookup)Wk 1Wk 2Wk 3Wk 4Wk 5OT ADJ.Total Monthly Commission $$Total YTD Sales $$
2TotalOTTotalOTTotalOTTotalOTTotalOT
3BH - Bridgette Henry$55,583.20$55,583.2026.30%$2,084.370$0.00$ -$2,084.37$55,583.20
4CNR - Crystal Rubis$0.00$0.000.00%$0.000$0.00$ -$0.00$0.00
5JEG - James Gillhooley$21,895.32$21,895.3230.10%$821.070$0.00$ -$821.07$21,895.32
6#REF!$1,581.49$1,581.4931.40%$0.000$0.00$ -$0.00$1,581.49
7SLB - Seana Brown$0.00$0.000.00%$0.000$0.00$ -$0.00$0.00
8TRACI - Traci Ritchey$14,937.57$14,937.5726.00%$560.160$0.00$ -$560.16$14,937.57
9
10
11
12
January
Cell Formulas
RangeFormula
G3:G8G3=IFERROR(IF((B3>VLOOKUP(A3,Personal,4,FALSE)),(((B3-VLOOKUP(A3,Personal,4,FALSE))*VLOOKUP(A3,Personal,3,FALSE))+(VLOOKUP(A3,Personal,4,FALSE)*VLOOKUP(A3,Personal,2))),B3*VLOOKUP(A3,Personal,2,FALSE)),0)
H3:H8H3=VLOOKUP(B3,Bogey,3)
I3:I8I3=+H3*1250
U3:U8U3=IFERROR((((J3/K3)/2)*L3)+(((J3/M3)/2)*N3)+(((J3/O3)/2)*P3)+(((J3/Q3)/2)*R3)+(((J3/S3)/2)*T3),0)
V3:V8V3=G3+I3+U3
W3:W8W3=+B3
B3:B8B3=+D3+C3
Named Ranges
NameRefers ToCells
Bogey=Bogey!$B$2:$G$28H3:H8
January=OFFSET(January!$A$3,0,0,COUNTA(January!$A:$A)-1,23)G3
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Try instead if rows have in column A error #REF!
VBA Code:
.SpecialCells(xlCellTypeFormulas, xlErrors).EntireRow.Delete
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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