+ Reply to Thread
Results 1 to 4 of 4

VBA Program to Count and populate a table

  1. #1
    Registered User
    Join Date
    03-23-2007
    Posts
    91

    VBA Program to Count and populate a table

    Hi,

    I need to write a program that does the following
    Assuming the sample data here.

    studyID Reviewr ID Color
    A Normal 1233 Blue
    R Special 1233 Blue
    A Normal 1234 Red
    B Normal 2222 Red
    R Special 2222 Red
    B Normal 2228 Yellow
    C Normal 3859 Yellow
    R Special 3859 Black
    C Normal 3477 Black
    D Normal 4447 Green
    D Normal 4448 Green
    R Special 4448 Green
    E Normal 7777 Yellow
    R Special 7777 Green

    And output

    Normal Special
    1 1
    2 2
    5 5
    3 5

    I need to return a number depending on which color is selected.
    Let's say Blue=1, Red=2, Yellow=3,Black=4, Green=5
    I need to check a whole and this will change so has to be done dynamically.
    So to get the output I would need to do the following.
    If ID=ID, and Reviewr=Normal and Color=Blue then populate the first entry with a 1.
    If ID=ID, and Reviewr=Special and Color=Blue then populate the first entry with a 1.
    If ID=ID, and Reviewr=Normal and Color=Yellow then populate the first entry with a 3.
    If ID=ID, and Reviewr=Special and Color=Green then populate the first entry with a 5.

    So the program should check all ID's in the column but only compare the ones that are equal.
    What would be the best way of doing this?
    I tried a formula but I'm thinking VBA might be better.
    Any insights?

    Thanks!



    Thanks for any insights.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: VBA Program to Count and populate a table

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    03-23-2007
    Posts
    91

    Re: VBA Program to Count and populate a table

    Here's a sample file.

    Thanks
    Attached Files Attached Files

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: VBA Program to Count and populate a table

    Dohko, if you opt to cross post the same question on multiple boards please have the courtesy to disclose all relevant links

    http://www.mrexcel.com/forum/showthread.php?t=502514

    Why ? http://www.excelguru.ca/node/7

    With 79 posts to your name you should be familiar with the Forum Rules - if not please read them.

+ 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