Help modifying Macro to also hide lines with zero values in column C

JPG963

New Member
Joined
Dec 7, 2015
Messages
13
Hello,
I am very new to excel and need assistance in modifying a existing macro to also hide any rows within the same range with a value of 0.00 in column "C". Thanks in advance

Here is my current macro:

Code:
'
' Sort Macro
'


'
    ActiveWorkbook.Worksheets("sheet1").Sort.SortFields.Clear


    ActiveWorkbook.Worksheets("sheet1").Sort.SortFields.Add Key:=Range("G7:G30") _
        , SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal


    With ActiveWorkbook.Worksheets("sheet1").Sort
        .SetRange Range("B7:I30")
        .Header = xlGuess
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
    Range("A10").Select
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Replace above code with:
Code:
Sub Macro SortAndHide()

Dim LR  As Long
    Dim LC  As Long
    Dim ws  As Worksheet
    
    Set ws = ActiveWorkbook.Worksheets("Sheet1")
    
    With ws
         If .AutoFilterMode Then .AutoFilterMode = False
         LR = Application.Max(7, .Cells(.rows.count, 7).End(xlUp).row)
         LC = .Cells(7, .Columns.count).End(xlToLeft).Column
         
        With .Cells(7, 1).Resize(LR - 6, LC)
            .Sort key1:=.Range("G7"), order1:=xlAscending, header:=xlYes
            .AutoFilter field:=3, Criteria1:="<>0.00"
        End With
        
    End With
    
    Set ws = Nothing

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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