How to set a skip a step when filter result is 0?

Martin1991

New Member
Joined
Nov 14, 2017
Messages
24
Hello,
I m trying to figure out, how to set my formula to skip a similar step after filtering out any values with 0 results. I m searching second day and can´t find any tip for this specific case. I´m beginner with VBA, so i hope it´ll be easy question for you.

To clarify, i got small simple macro, which should fill special cells with some "memo" according the criterial values.
1. Macro filters out, what i need.
2. Fills special cells with "memo".
3. Reset my filters.

Problem is step 2. When filter can´t find defined criteria (because i work daily with another documents, and sometimes there are those criterias, sometimes not), it fills up not only special cells, but every single cell (not only visible) in current column except the first raw, which is header.

Code:
Sub HQstatuses()

    Sheets("Data").Select
    ActiveSheet.UsedRange.AutoFilter Field:=88, Criteria1:=Array( _
        "HQ can´t support*", "HQ pending - shortage*"), Operator:=xlFilterValues
    
    ActiveSheet.UsedRange.AutoFilter Field:=65, Criteria1:=Array( _
        "Y"), Operator:=xlFilterValues
        
    x = ActiveWorkbook.Sheets("Data").Range("CA1").CurrentRegion.Rows.Count


    vzoreccheck = "oow/cid-HQ pending - shortage, please choose a sub with different color"
    
    Range(Cells.SpecialCells(xlCellTypeVisible)(2, 79), Cells.SpecialCells(xlCellTypeVisible)(x, 79)).Value = vzoreccheck
    ActiveSheet.Calculate
    ActiveSheet.ShowAllData
    
End Sub


What kind of changes would you recommend to me? I think, its about some IF condition, tryed to set it by IF with another formula "y": y = SpecialCells(xlCellTypeVisible).Count ---> If y > 1 Then calculate, but it doesn´t work.

I´m new to the Forum, read all board rules, so i hope its all understandable. :)
 
In that case try
Code:
Dim x As Long, c As Range
x = ActiveWorkbook.Sheets("Sheet1").Range("BZ1").CurrentRegion.Rows.Count
    
    For Each c In Worksheets("Sheet1").Range("BZ1:BZ" & x).SpecialCells(xlVisible)
     If c.Value > 88 Then
        c.EntireRow.Style = "Bad"
     End If
    Next c
 
Upvote 0

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
I tryed and unfortunately, its marking again even non-filtered cases, which is a bit weird. It seems like everything is allright.
 
Upvote 0
I tryed and unfortunately, its marking again even non-filtered cases, which is a bit weird. It seems like everything is allright.
This is a bit confusing :confused:
Are you saying everything is ok?
Or are you saying it's not working correctly?
 
Upvote 0
At first. I´m sorry for late reply, but i hadn´t access to my work notebook, so i couldn´t check with excel. Then I´m sorry for confusing answer.
I used it, and on the first testing, it seemed, that it doesn´t work. So i wrote it, but the end of the sentence was my point of view, when i checked the code.

Finally i tested it for a while, tried some combines of this code and it works perfectly! So, yes everything is allright. Thank you very much!
 
Upvote 0
Glad it's sorted & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,301
Members
452,633
Latest member
DougMo

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