+ Reply to Thread
Results 1 to 2 of 2

Copying columns of data from one sheet to another based on multiple criteria

  1. #1
    Registered User
    Join Date
    02-20-2017
    Location
    Copenhagen, Denmark
    MS-Off Ver
    2013
    Posts
    1

    Copying columns of data from one sheet to another based on multiple criteria

    Hi all,

    I’m totally new with using spreadsheets and can’t seem to find a topic in the forum, which matches my assignment. Please see the attached file. The xlsm file was too big to upload, so I’ve taken a couple of screen dumps of the two sheets instead.

    In the first sheet “Risikolog”, there are numerous variables separated by columns. I’m interested in “Rapport”, “System/Område”, “Trussel/scenarie”, “K-talværdi”, and “S-talværdi”. I have cleared the other columns due to confidentiality. “Risikolog” is thus the main source of data and needs no further coding.

    In the second sheet “Afrapportering”, I need the ability to select e.g. 2015_2016 in B2 and Serverrum in C2 from a drop-down list. I need to be able to select all possible values from the cells. These serve as the filtering criteria. Next, the data rows from “Risikolog”, which fulfill the criteria, automatically copy the according data from “Trussel/Scenarie”, “K-værdi”, “S-værdi”, and “Risikoniveau” in sheet “Risikolog” into the sheet “Afrapportering”.

    In this mockup, the sheet “Afrapportering” displays 3 Trussel/Scenarie (Threats/Scenarios), along with their K-værdi (Consequence), S-værdi (likelihood) and Risikoniveau (Risk Level) because these are the only threats, which are from 2015_2016 and Serverrum.

    So, can this be done?

    Hope it makes sense. Thanks in advance

    Kind regards.
    Attached Images Attached Images

  2. #2
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    It varies ...
    MS-Off Ver
    Office365 - 64bit
    Posts
    862

    Re: Copying columns of data from one sheet to another based on multiple criteria

    As you're new to spreadsheets, I would point out that much of what you do when collecting data and reporting on it will depend on data quality and field standardisation.

    For example, in the Risikolog sheet, rows 3, 4 and 5 has data missing in them, such as the Rapport. This means the records in these rows would never be picked up in the Afrapportering sheet because they do not have a year against them - just as they would not if you applied a filter in the Rapport column in the Risikolog sheet.

    Another example is that the Risikolog sheet has the years as 2016, 2017 and so on, but your example of filtering by year proposes a format of "2015_2016" to mean "in either 2015 or 2016". If you intend using the underscore (_) between two years in all cases, that can be done but poses an unnecessary complication of extracting the from/to years when you could just have them separately in the Afrapportering sheet.

    There are also many ways to achieve the same thing; you don't actually need to duplicate the filtering fields in Afrapportering - you could instead filter by whichever columns you want to in Risikolog using the autofilter you've got in the header and export the filtered results to another sheet (e.g. Afrapportering), which is what I suggest. Doing it this way, you're also not restricted to filtering only by the date & severity fields.

    I would normally use named ranges to reference columns under the headings you need reported as this avoids using explicit references to them but I'm not sure if you know what they are or how to set them up. The "offset" references in the code below are a relative reference from the first column, which means if you add/remove columns, the data returned will be wrong. If you know how to apply named ranges then let me know what you named them (or just send an updated file) and I'll change the code.

    Code is below - you need to paste this into the code window of the Afrapportering sheet.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by MatrixMan; 03-01-2017 at 02:21 PM. Reason: Uploaded solution file
    MatrixMan.
    --------------------------------------
    If this - or any - reply helps you, remember to say thanks by clicking on *Add Reputation.
    If your issue is now resolved, remember to mark as solved - click Thread Tools at top right of thread.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Copying Data based on multiple criteria
    By ImranBhatti in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-29-2016, 02:01 PM
  2. Replies: 3
    Last Post: 07-18-2015, 02:06 PM
  3. [SOLVED] Copying data based on multiple criteria from one sheet to another
    By excellearner121 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-01-2014, 01:52 AM
  4. Replies: 7
    Last Post: 09-30-2014, 01:44 PM
  5. Selecting Multiple columns based on headers and copying to seaperate sheet
    By jonto81 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-03-2013, 10:44 AM
  6. Copying a row of data to another sheet based on criteria in first sheet
    By Carl Mukluk in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 02-19-2013, 08:01 AM
  7. Replies: 4
    Last Post: 01-08-2013, 12:37 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1