Dynamically Pulling Data between Worksheets

AGMGCM

New Member
Joined
Feb 8, 2018
Messages
5
Hello,

I am trying to do a small pull of data between two worksheets but in an active manner, I'm hoping someone here might be able to figure this one out as I can't come up with a perfect solution.

Sample Data on Worksheet1:

Sample-Data.jpg


On Worksheet2 I would like to pull anything that says 'Yes' in Worksheet1's Column A - this is using a data validation list of Yes/No

Desired results for Worksheet2:

Sample-Data2.png


I would like this to be dynamic so that anything switched to Yes shows up on Worksheet2 and when it switches to No, it disappears from Worksheet2. I understand that something like this could be done in Access but I would like to keep this in Excel if possible.

Thank you
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hello,

If this is Worksheet1

ABCD
1CompileManufacturerProduct Price
2YesWhite Sky Inc.Solar flashlight $ 22.83
3NoEasy PartnersRubber ladder $ 12.32
4NoACME WidgetsCat trainer $ 9.00
5YesHope & Sky Inc.Tissue umbrella $ 230.22

<tbody>
</tbody>
Worksheet1
Then this formulae should work:
=IF(COUNTIF(Worksheet1!$A$2:$A$20,"Yes") < ROWS(A$1:A1),"",INDEX(Worksheet1!A$2:A$20,AGGREGATE(15,6,ROW(Worksheet1!$A$2:$A$20)-ROW(Worksheet1!$A$1)/(Worksheet1!$A$2:$A$20="Yes"),ROWS(A$1:A1))))

Put it in Worksheet2 cell A2. Change the $20 to the maximum row number you'll ever have (say $9999) and copy it down that many rows. Now highlight those cells and copy across the number of columns where you have data.

ABCD
1CompileManufacturerProduct Price
2YesWhite Sky Inc.Solar flashlight22.83
3YesHope & Sky Inc.Tissue umbrella230.22
4

<tbody>
</tbody>
Worksheet2

Worksheet Formulas
CellFormula
A2=IF(COUNTIF(Worksheet1!$A$2:$A$20,"Yes") < ROWS(A$1:A1),"",INDEX(Worksheet1!A$2:A$20,AGGREGATE(15,6,ROW(Worksheet1!$A$2:$A$20)-ROW(Worksheet1!$A$1)/(Worksheet1!$A$2:$A$20="Yes"),ROWS(A$1:A1))))
B2=IF(COUNTIF(Worksheet1!$A$2:$A$20,"Yes") < ROWS(B$1:B1),"",INDEX(Worksheet1!B$2:B$20,AGGREGATE(15,6,ROW(Worksheet1!$A$2:$A$20)-ROW(Worksheet1!$A$1)/(Worksheet1!$A$2:$A$20="Yes"),ROWS(B$1:B1))))

<tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
The first part of your request would be simple:
But the second part about deleting the row from Sheet(2) would be more complicated.
Will the value on Sheet(2) column A change to "No" or did you mean if the value in column A of sheet(1) changes to "No"

If it's when value on sheet(1) changes to "No" how would we know what row on sheet(2) to Delete.
Is their any unique value on the row to identify the row.
If you mean when "No" in entered into column A of Sheet(2) it would be simple.


Here is the way to do the first part:

This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet (1) Tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

When you enter "Yes" into column A of Sheet(1) the script will run.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified  8/25/2019  12:49:26 AM  EDT
If Target.Column = 1 And Target.Value <> "" Then
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub
Dim lastrow As Long
lastrow = Sheets(2).Cells(Rows.Count, "A").End(xlUp).Row + 1
    Select Case Target.Value
        Case "Yes"
        Rows(Target.Row).Copy Sheets(2).Rows(lastrow)
        Case "No"
    
    End Select
End If
End Sub
 
Upvote 0
I would take a somewhat similar approach to Toadstool but there are quite a lot of things being calculated multiple time in that suggestion so I have used a helper column & helper cell to save calculating so much.

Here is my Worksheet1 with just some random numbers as dummy data in columns B:G (We cannot copy your sample data from images like you posted. See my signature block below for help on how to post data that can be copied - like Toadstool & I have done in this thread)

Column H is my helper column but it could be any column & it could be hidden after entering the formulas.
Cell H1 is left empty
Formula in H2 is copied down to the end of your data or the end of wherever your data might eventually come to.

Excel Workbook
ABCDEFGH
2No8324714568800
3No502112995510
4Yes893311953531
5Yes5676899896502
6No1152243189972
7Yes9353251231593
8No3340655197503
9Yes563508743434
10No3019848330984
11Yes572787968435
12No76747361585
13No13374799205
14Yes109587645306
15No881428262586
16Yes41890693407
17No653625642557
18No9020121286147
19No81546430277
207
217
Worksheet1



In Worksheet2 I have used cell Z1 as a helper cell. Again it could be another cell & the column can be hidden if you want.
Formula in A2 is copied down as far as you might ever need.
Formula in B2 is copied (after adjusting the max row $1000 if needed) across and down as far as column A was.

Excel Workbook
ABCDEFGHIZ
17
2Yes89331195353
3Yes567689989650
4Yes935325123159
5Yes56350874343
6Yes57278796843
7Yes10958764530
8Yes4189069340
9
10
Worksheet2
 
Upvote 0

Forum statistics

Threads
1,214,548
Messages
6,120,141
Members
448,948
Latest member
spamiki

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