86 Seconds to run my bit of Code to delete blank rows ! Would like it to run faster, learning

DarrenBurke

New Member
Joined
May 6, 2022
Messages
29
Office Version
  1. 2016
  2. 2007
Platform
  1. Windows
Evening all
Need to remove blank rows from worksheet. They cause an untidy database. 86 seconds to clear the blanks..... it works but i am sure the hive minds can make it run faster

My Xl2BB

Michael Pickup.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXY
1A/ CODENUMNUMDATE CREATEDREFNUMPICK-UP DATECOMPANYBUILDINGSTREET ADDRESSSUBURBTOWNCROSS ROADCONTACT 1CONTACT 2TEL NUMBERFAX NUMBERREPRESENTATIVEDONATQTYDELIVER PRODUCTA/ CODENUMNUMF/CODENUMNUM
201254823542022/07/07MF3552022/07/08ZAMBESI GLASS&ALUMINIUMMONTANA VALUE CENTRE151 CALLIANDRA STRMONTANAPRETORIATIBOUCHINACORINRECEPTION012MICHAEL FERREIRAGlass1TAX INVOICE0125482354
301190826542022/07/06MF3542022/07/07JMR TRANSPORT SOLUTIONS(PTY)LTD4 BORAX STREETALRODEALBERTONMEV HEYSTECKASK FOR HER CASH011CASHMICHAEL FERREIRA550,001TAX INVOICE0119082654CASH
401179336952022/07/06MF3512022/07/07GRAYTEX METALS375 KRUGER STREETSTRIJOMPARKRANDBURGBRINAS PER JASON011CASHMICHAEL FERREIRA200,001TAX INVOICE0117933695CASH
508297256472022/07/06MF3522022/07/07CAR CLINIC49 SHAFT ROADKNIGHTSGERMISTONJANNIEINA082CASHMICHAEL FERREIRA100,001TAX INVOICE0829725647CASH
607613931262012/10/18MF10152012/10/22THE BRAZEN HEADRIVER CRESENT CENTREC/O BETHALWITBANKMANDELANICK CHRISOCHOFFBERNI076MICHAEL FERREIRA150,001TICKETS0761393126
701328260782012/10/18MF10142012/10/22NU MID GLASSAGTER POSKANTOOR26 SADC STRMIDDELBURGPATDASSIE013MICHAEL FERREIRA200,001TAX INVOICE0132826078
808233963282012/10/17MF10132012/10/18ANTON LOMBAARD INC.OAK AVENUE OFFICE PARK372 OAK AVENUEBTF PAYMENTFERNDALEANTON LOMBAARDLIZ082MICHAEL FERREIRA400,001SHERRY HAMPER0823396328
901375276532012/07/04MF8622012/07/05LOWVELD COMPRESSOR SERVICESATLAS COPCO14 OLD PRETORIA ROADVINTONIANELSPRUITFRANCOISMARALIZE013MICHAEL FERREIRA600,0014 X BOOKS TICKETS0137527653
1001191859612008/01/01MF2092019/04/03LARMESH EXPANDED METALS07 TOP RDANDERBOLTBOKSBURGROBERTKIRST011MICHAEL FERREIRA500,001TAX INVOICE0119185961
1101189447142008/01/01MF2102008/01/03CRYSTAL SPIRITSLAKEFIELD SQRLAKEFIELD AVELAKEFIELDBENONI0CHANTEL0011MICHAEL FERREIRA100,001TAX INVOICE0118944714
1208233963282012/10/17MF10132012/10/18ANTON LOMBAARD INC.OAK AVENUE OFFICE PARK372 OAK AVENUEBTF PAYMENTFERNDALEANTON LOMBAARDLIZ082MICHAEL FERREIRA400,001SHERRY HAMPER0823396328
1301375276532012/07/04MF8622012/07/05LOWVELD COMPRESSOR SERVICESATLAS COPCO14 OLD PRETORIA ROADVINTONIANELSPRUITFRANCOISMARALIZE013MICHAEL FERREIRA600,0014 X BOOKS TICKETS0137527653
1401191859612008/01/01MF2092019/04/03LARMESH EXPANDED METALS07 TOP RDANDERBOLTBOKSBURGROBERTKIRST011MICHAEL FERREIRA500,001TAX INVOICE0119185961
1501254823542022/07/07MF3552022/07/08ZAMBESI GLASS&ALUMINIUMMONTANA VALUE CENTRE151 CALLIANDRA STRMONTANAPRETORIATIBOUCHINACORINRECEPTION012MICHAEL FERREIRAGlass1TAX INVOICE0125482354
1601190826542022/07/06MF3542022/07/07JMR TRANSPORT SOLUTIONS(PTY)LTD4 BORAX STREETALRODEALBERTONMEV HEYSTECKASK FOR HER CASH011CASHMICHAEL FERREIRA550,001TAX INVOICE0119082654CASH
1701254823542022/07/16MF777ZAMBESI GLASS&ALUMINIUMMONTANA VALUE CENTRE151 CALLIANDRA STRMONTANAPRETORIATIBOUCHINACORINRECEPTION012MICHAEL FERREIRA1TAX INVOICE0125482354
1801189447142022/07/16MF999CRYSTAL SPIRITSLAKEFIELD SQRLAKEFIELD AVELAKEFIELDBENONICHANTEL011MICHAEL FERREIRA1TAX INVOICE0118944714
1901190826542022/07/16MF1JMR TRANSPORT SOLUTIONS(PTY)LTD4 BORAX STREETALRODEALBERTONMEV HEYSTECKASK FOR HER CASH011MICHAEL FERREIRA1TAX INVOICE0119082654
2008233963282022/07/16MF1ANTON LOMBAARD INC.OAK AVENUE OFFICE PARK372 OAK AVENUEBTF PAYMENTFERNDALEANTON LOMBAARDLIZ082MICHAEL FERREIRA1TAX INVOICE0823396328
21 2022/07/1611TAX INVOICE
22 2022/07/1611TAX INVOICE
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
DATABASE BUILDING
Cell Formulas
RangeFormula
A1:A36A1=CONCATENATE(T1,U1,V1)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C:CCellcontains a blank value textNO
Q2:Q11Cell Value="0.00"textNO
C:CCellcontains a blank value textNO

My Current VBA it works but 86 seconds for such a small amout of data to check, at a loss

VBA Code:
Option Explicit

Sub sbDelete_Rows_IF_Cell_Is_Blank1()

Application.ScreenUpdating = False

    Dim lRow As Long
    Dim iCntr As Long
        lRow = 1500
    For iCntr = lRow To 1 Step -1
    If Trim(Cells(iCntr, 1)) = "" Then
        Rows(iCntr).Delete
    End If
    Next

    Range("A2").Select
    Selection.AutoFill Destination:=Range("A2:A1500"), Type:=xlFillDefault
    Range("A2:A1500").Select
        Range("B1").Select
    Application.ScreenUpdating = True

End Sub

Thank you for your time
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Any reason that you cannot continue to use the code that "works in milliseconds" per your comment here?
 
Upvote 0
Give this a try.

VBA Code:
Option Explicit
Sub sbDelete_Rows_IF_Cell_Is_Blank1()
    Dim i As Long
    Dim lastrow As Long
    lastrow = Cells(rows.Count, "A").End(xlUp).Row
    Application.ScreenUpdating = False
   
    For i = lastrow To 2 Step -1
        If Range("A" & i).Value = "" Then Range("A" & i).EntireRow.Delete
    Next i

    Range("A2").Select
    Selection.AutoFill Destination:=Range("A2:A1500"), Type:=xlFillDefault
    Range("A2:A1500").Select
    Range("B1").Select
   
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
BTW, isn't the bottom part of that code in post #1 just going to re-fill all those rows with formulas returning exactly what is in them now?

Are all the blanks together at the bottom of the other non-blank values in column A like your sample?
 
Upvote 0
BTW, isn't the bottom part of that code in post #1 just going to re-fill all those rows with formulas returning exactly what is in them now?

Are all the blanks together at the bottom of the other non-blank values in column A like your sample?
I thought the same, but figured this was just an example and maybe its required the real document?
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,632
Latest member
jladair

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