Multiple sheets feed into one sheet based on response

manzier

Board Regular
Joined
Jul 21, 2014
Messages
96
Hi,

I have a bit of a tough one here.

I have multiple spreadsheets (each with the same format). Here's an example of what one spreadsheet would look like

AnswerNumberActionDate
Yes1.1
No1.2This will be an action5/30/15
No1.3Another action6/5/15

<tbody>
</tbody>

Basically, every time you answer "No" you'll need to put in an action and a due date. I have about 20 sheets in this format. What I want to do is create another worksheet that will get all the "No" answers from each tab and put it in one sheet. Example:

1.2This will be an action5/30/15
1.3Another action6/5/15
2.1Another action from another tab6/5/15
3.4and another one7/1/15

<tbody>
</tbody>


What's the best way of going about this?

Thanks for the help!
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Hello Manzier,

Perhaps the following code may do the job for you:-

Code:
Sub CopyData()
Dim ws As Worksheet
Dim lRow As Long
Dim lCol As Integer

Application.ScreenUpdating = False

For Each ws In Worksheets
    If ws.Name = "Summary" Then GoTo NextSheet
    
    ws.Select
    
    lRow = Range("A" & Rows.Count).End(xlUp).Row
    lCol = Cells(1, Columns.Count).End(xlToLeft).Column
    
    For Each cell In Range("A2:A" & lRow)
        If cell.Value = "No" Then
            Range(Cells(cell.Row, "A"), Cells(cell.Row, lCol)).Copy
            Sheets("Summary").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
            'Range(Cells(cell.Row, "A"), Cells(cell.Row, lCol)).ClearContents
        End If
    Next cell

NextSheet:
Next ws

Sheets("Summary").Columns.AutoFit
Sheets("Summary").Select
Application.ScreenUpdating = True
Application.CutCopyMode = False

End Sub


This line of code:-
Code:
'Range(Cells(cell.Row, "A"), Cells(cell.Row, lCol)).ClearContents

has an apostrophe in front of it. If you want to clear the "used" data from the different sheets as you go then just remove the apostrophe and the transferred rows of data will be cleared. This will also prevent duplication in the Summary sheet.

Attached is my sample work book for you to peruse.

https://www.dropbox.com/s/ptd9mm81ufsw0as/Manzier(Multiple sheets to Summary).xlsm?dl=0

I hope that this helps.

Cherrio,
vcoolio.
 
Upvote 0
This is perfect vcoolio, thank you!

One question though: If I wanted to pick which columns I wanted to copy paste, as opposed to just taking the row, how would I write that into VBA? For example, if I wanted to copy paste only columns D, F, I, and J?

Thank you for your help.
 
Upvote 0
Hello Manzier,

I slapped this together for you:-
Code:
Sub CopyData()
Dim ws As Worksheet
Dim lRow As Long

Application.ScreenUpdating = False

For Each ws In Worksheets
    If ws.Name = "Summary" Then GoTo NextSheet
    
    ws.Select
    
    lRow = Range("A" & Rows.Count).End(xlUp).Row
    
    For Each cell In Range("A2:A" & lRow)
        If cell.Value = "No" Then
            Range(Cells(cell.Row, "D"), Cells(cell.Row, "D")).Copy
            Sheets("Summary").Range("A" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
            Range(Cells(cell.Row, "F"), Cells(cell.Row, "F")).Copy
            Sheets("Summary").Range("B" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
            Range(Cells(cell.Row, "I"), Cells(cell.Row, "J")).Copy
            Sheets("Summary").Range("C" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
            'Range(Cells(cell.Row, "A"), Cells(cell.Row, lCol)).ClearContents
        End If
    Next cell

NextSheet:
Next ws

Sheets("Summary").Columns.AutoFit
Sheets("Summary").Select
Application.ScreenUpdating = True
Application.CutCopyMode = False

End Sub


https://www.dropbox.com/s/rgrtqu8nxc1n6if/Manzier(2).xlsm?dl=0

I hope its what you are wanting....................running late for work.....

Cheerio,
vcoolio.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,203,606
Messages
6,056,280
Members
444,854
Latest member
goethe168

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