+ Reply to Thread
Results 1 to 5 of 5

Creating a VBA code for the report

  1. #1
    Registered User
    Join Date
    12-28-2016
    Location
    Switzerland
    MS-Off Ver
    2010
    Posts
    9

    Question Creating a VBA code for the report

    Ladies and Gentlemen,

    I have an issue. I am dealing with at least 12k to 15k lines of Data that I am converting to a "usable" report.

    This report contains over 120 rules that are defining, who will be responsible. The Rules itself are built with "IF" ruling. Some of them are pretty straight forward, some of them has multiple IFs and comparing 2 - 3 cells to come up with the result.

    I made an example (very much simplified) for you guys to have a visual. Unfortunately, I cannot upload the real data due to security issues.

    The file i have prepared contains 2 sheets:

    Current Scenario with simplified Rules
    Goal Scenario with VBA ( I was hoping I could reach this kind of scenario with help of VBA)

    Sheet Current Scenario:
    Column L: This is some of those straight forward rules
    Column M: This is one of those "special rules"

    Every month, there are new rules coming I am building in. I would like to have it more structurized and sustainable which I think I can only do if I use "cases" via VBA.

    Could you please help me out here? Like an example of the VBA code that I can use as a Foundation for this report?

    Thank you very much in advance!

    Kind regards

    Nxvle
    Attached Files Attached Files
    Last edited by Nxvle; 12-28-2016 at 07:56 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Ipswich, England
    MS-Off Ver
    MS 365 Subscription Insider (Windows 10)
    Posts
    50,935

    Re: To VBA or not to VBA?

    Welcome to the forum! Please take a moment to re-read forum rule #1 and then amend your thread title to something that better explains your problem. Changing your thread title is not optional. Thanks!

    No help to be offered, please, until the thread title has been clarified.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!

    Forum Rules (updated September 2018): please read them here.
    How to use the Power Query code you've been given: help here. More about the Power suite here.
    Don't forget to say "thank you" to those who have helped you in your thread. If you wish, you can also reward them by clicking on their reputation star bottom left.

  3. #3
    Registered User
    Join Date
    12-28-2016
    Location
    Switzerland
    MS-Off Ver
    2010
    Posts
    9

    Re: To VBA or not to VBA?

    Done, Thank you very much

  4. #4
    Forum Moderator Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    28,420

    Re: Creating a VBA code for the report

    In addition to changing the title as Ali has asked note the following.

    This is clearly a much simplified example and probably doesn't represent the size or complexity of your actual data. We often find that when we give an answer to what is a trivial non representative example when the solution is used with the real world data it doesn't work because of factors like string length and other stuff which is important but hasn't been mentioned and which causes wasted time and effort.

    Therefore upload your real workbook (or at least a cut down copy), and manually add the results you expect to see. Clearly identify which is original data and which are the results and in a note clearly explain how you have arrived at your results.
    Anonymise it as necessary to overcome any security/data protection issues. We don't mind how many Donald Ducks, Mickey Mouses or 1 Anytown, Anywhere, names or addresses appear.
    Richard Buttrey

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Registered User
    Join Date
    12-28-2016
    Location
    Switzerland
    MS-Off Ver
    2010
    Posts
    9

    Re: Creating a VBA code for the report

    Quote Originally Posted by Richard Buttrey View Post
    In addition to changing the title as Ali has asked note the following.

    This is clearly a much simplified example and probably doesn't represent the size or complexity of your actual data. We often find that when we give an answer to what is a trivial non representative example when the solution is used with the real world data it doesn't work because of factors like string length and other stuff which is important but hasn't been mentioned and which causes wasted time and effort.

    Therefore upload your real workbook (or at least a cut down copy), and manually add the results you expect to see. Clearly identify which is original data and which are the results and in a note clearly explain how you have arrived at your results.
    Anonymise it as necessary to overcome any security/data protection issues. We don't mind how many Donald Ducks, Mickey Mouses or 1 Anytown, Anywhere, names or addresses appear.
    Hello Richard,

    yes that is true. The complexity itself, its not that complex:

    =IF(A2="T024";"SNP";IF(A2="T047";"SNP";IF(A2="T059";"SNP";IF(A2="T060";"SNP";IF(A2="T064";"SNP";IF(A2="P004";"SNP";IF(A2="P008";"SNP";IF(A2="P009";"SNP";IF(A2="P017";"SNP";IF(A2="P019";"SNP";IF(A2="P040";"SNP";IF(A2="P042";"SNP";IF(A2="T086";"CSDM";IF(A2="T087";"CSDM";IF(A2="P021";"CSDM";IF(A2="P022";"CSDM";IF(A2="P025";"CSDM";IF(A2="P030";"CSDM";IF(A2="P031";"CSDM";IF(A2="P034";"CSDM";IF(A2="P035";"CSDM";IF(A2="P036";"CSDM";"RULE"))))))))))))))))))))))

    This is for exa,ple what I sue for straight forward ruling.

    This is an example of a "more complex" ruling I use:
    =IF(A2="T020"; IF(H2="VMI";"CSDM";IF(H2="DC";"CSDM";IF(H2="MFG";"PPDS";"SNP"))))

    So when new rule comes, I just modify one of the old rules and then it works.

    The purpose of this is to convert this ruling in to VBA coding if applicable.

    Thank you for your guidance.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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