Copy/paste data only for relevant sheets VBA

Danoz

New Member
Joined
Jul 22, 2010
Messages
39
Hi All

Using Excel 07

I'm setting up a macro enable workbook which produces results (up to 13) based on a number of criteria. The macro currently unhides the result number of sheets that already exist, so if there's 4 results, "All Results", "Result 1", "Result 2", "Result 3" and "Result 4" will unhide. Each sheet will have an assigned value such as A150, A238, A412, A567 and A320. They are variable based on a set of raw data that is new every time the workbook is used. The raw data is used to assign the values.



What I want to do next is to populate certain cells in "All Results", "Result 1", "Result 2", etc. based on the assigned values. Points that may help:


What sheets are unhidden is based on formulae in 'Lists'!$S$2:$V$14
S2 = Result 1 T2 = A value (A238) V2 = TRUE
S3 = Result 2 T3 = A412 V3 = TRUE
... ... ...
S13 = Result 12 T13 = #N/A (no result) V13 = FALSE
S14 = All Results T14 = A150 V14 = TRUE


So where TRUE is returned, that sheet is made visible.In my head the logic goes thus;



Copy row of sheet(Data Extract) in which value in sheet(Lists)$T$2..>..$T$14 appears in column D and integer in sheet(Result 1)$I$48 appears in column N and paste in sheet(Result 1)$I$54
then copy all other rows of sheet(Data Extract) in which value in sheet(Lists)$T$2..>..$T$14 appears in column D and paste in sheet(Result 1)$I$57 down
Repeat for each value in 'Lists'!$T$2:$T$14 where value in 'Lists'!$V$2:$V$14 is TRUE


I appreciate if anyone is able to help me out, and happy to provide anything else that is required.



Thanks,
Dan
 
Last edited:

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Is my question too vague or lacking somethign that would make it answerable?

Does this help?

So I currently have the following code

Code:
' Show required sheets
    Dim rng As Range
    Set rng = ThisWorkbook.Sheets("Lists").Cells.Range("S2:S13")
    For Each c In rng
        If c.Offset(0, 3).Value = "True" Then
            Sheets(c.Value).Visible = True
        Else:
            Sheets(c.Value).Visible = False
        End If
    Next

Could I possibly add some code after making sheets visible? I've avoided doing this so far because it seems the code above is more a blanket and attempting to put individual sheet code in there would fail?

Thanks,
Dan
 
Upvote 0

Forum statistics

Threads
1,215,580
Messages
6,125,654
Members
449,245
Latest member
PatrickL

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