Dynamic cell Macro

doriannjeshi

Active Member
Joined
Apr 5, 2015
Messages
273
Office Version
  1. 365
Platform
  1. Windows
Hi

I need to delete the row where the total is less than 1. Possible to have this macro dynamic , totals column is always going to be at the end of the range!

Book2
ABCDEFG
1ABCDEFTOTAL
211-310
31111116
41111116
51111116
6111115
7111115
81111116
9111-61-2
1011114
111111116
12111115
131111116
14111115
sheet1
Cell Formulas
RangeFormula
G2:G14G2=SUM(A2:F2)
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
If possible also to sort z-a from the total column with the macro
Not while the column is formulas rather than values as they'll recalculate.
Try the code below (uncomment the sort line if you convert the formulas to values)

VBA Code:
Sub doria()
    Dim lc As Long, lr As Long
    Application.ScreenUpdating = False
   
    lc = Cells(1, Columns.Count).End(xlToLeft).Column
    lr = Cells(Rows.Count, lc).End(xlUp).Row

    With Range(Cells(1, lc), Cells(lr, lc))

        .AutoFilter 1, "<1"
       
        On Error Resume Next
        .Offset(1).SpecialCells(xlCellTypeVisible).EntireRow.Delete
       
        On Error GoTo 0
        .AutoFilter
        '.Sort .Cells(1), xlDescending, , , , , , xlYes
   
    End With

    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,577
Messages
6,173,164
Members
452,504
Latest member
frankkeith2233

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