Excel Conditional Loop without VBA?

TMervis

New Member
Joined
Jul 20, 2017
Messages
10
On Sheet1, i have two columns: (a) Sale_Date, (b) Sale_Status.
On Sheet2, i want to generate a consecutive list of those Sale_Dates whose Sales_Status is "Pending".
I'm on Excel 16 and i don't want to use VBA. I don't want to either just use a filter and copy.
thanks
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
You can use a pivottable for this I guess. I've made a simple setup:

Column A: Names
Column B: Dates
Column C: Status

Select data - Insert - Pivottable

Rows: Date & Name
Columns: Status (Filter on Pending)
Values: Count of Name or whatever you want to see. :)

Hope this helps.
 
Upvote 0
try this, not test tho.
Code:
Sub test()


Application.ScreenUpdating = False


Dim lRow As Long
Dim i As Long
Dim wsh1 As Worksheet
Dim wsh2 As Worksheet
Dim stxt As String


Set wsh1 = ActiveWorkbook.Sheets("Sheet1")
Set wsh2 = ActiveWorkbook.ActiveSheet 'this is your Sheet1, put a button in Sheet2
lRow = wsh1.Cells(Rows.Count, 1).End(xlUp).Row
stxt = "Pending"


For i = 2 To lRow 'assuming your data in sheet1 is tarting in row 2, row 1 is the header, change 2 to whatever row your starting data is


    If wsh1.Cells(i, 2) = stxt Then
        With wsh1
            .Range(.Cells(i, 1), .Cells(i, 2)).Copy Destination:=wsh2.Range("A99999").End(xlUp).Offset(1, 0)
        End With
    End If
    
Next i


Application.ScreenUpdating = True


End Sub
 
Last edited:
Upvote 0
Hi
Welcome to the board

Another option is to do the extraction using the Advanced Filter.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,053
Latest member
Mesh

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