Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok further to our chat discussions, here is my autofilter approach.</p> <p><strong>Your Requirement</strong></p> <blockquote> <p>First i want to delete rows in cole 6 that have "" also i am storing two dates in variables n1 and n2 now if col 4 > n1 And col 3 &lt; n2 Then delete please ignore CNF condition as some of my data has some exceptions to this which i want to keep</p> </blockquote> <p>Let's say your data looks like this</p> <p><img src="https://i.stack.imgur.com/SJSsC.png" alt="enter image description here"></p> <p>Now let's say <code>N1 = 5/1/2012</code> and <code>N2 = 7/1/2012</code></p> <p>If you visually see the screenshot then you will notice that there is only one row which meets the condition and that is Row 9 (Employee 623***).</p> <p><strong>Code</strong></p> <p>I have commented the code so that you will not have a problem understanding it.</p> <pre><code>Sub Sample() Dim ws As Worksheet Dim FltrRng As Range Dim lRow As Long Dim N1 As Date, N2 As Date Set ws = ThisWorkbook.Worksheets("Temp Calc") '~~&gt; Start Date and End Date N1 = #5/1/2012#: N2 = #7/1/2012# With ws '~~&gt; Remove any filters .AutoFilterMode = False '~~&gt; Get the last row lRow = .Range("A" &amp; .Rows.Count).End(xlUp).Row '~~&gt; Identify your data range Set FltrRng = .Range("A1:F" &amp; lRow) '~~&gt; Filter the data as per your criteria With FltrRng '~~&gt; First filter on blanks .AutoFilter Field:=6, Criteria1:="=" '~~&gt; Next filter on Start Date .AutoFilter Field:=3, Criteria1:="&gt;" &amp; N1, Operator:=xlAnd '~~&gt; Finally filter on End Date .AutoFilter Field:=4, Criteria1:="&lt;" &amp; N2, Operator:=xlAnd ' '~~&gt; And so on if required ' '~~&gt; Delete the filtered rows .Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete End With '~~&gt; Remove any filters .AutoFilterMode = False End With End Sub </code></pre> <p><strong>After Screenshot</strong></p> <p>If you notice that the required record has been deleted.</p> <p><img src="https://i.stack.imgur.com/EQX9M.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload