Consulting

Results 1 to 3 of 3

Thread: Using a worksheet as a database

  1. #1
    VBAX Newbie
    Joined
    Jul 2008
    Posts
    1
    Location

    Using a worksheet as a database

    I'm relatively new to VBA, and I can't seem to get my head around this problem.

    I have somewhere around 18,000 items that need to be classified in the following way:
    1) Each item is a string of 10 digits, i.e., 1234567890.

    2) The first four digits either belong to only one classification or belong to more than one classification.
    ex: If the classifications are Cheese, Pepperoni, Sausage, and Mushroom, then our example of 1234 belongs to one or more of the classifications. In this example case, it could belong to Cheese or Sausage.

    3) If the first four digits belong to more than one classification (such is the case with our example), then the next two digits are the next case we look at.
    ex: 1234 is split up such that if the next two digits are from 00 to 45, the item belongs to Cheese. If the next two digits are from 46 to 60, the item belongs to Sausage. Therefore, our example of 1234-56 belongs to Sausage.

    4) Whatever classification is determined needs to be inserted into a new column next to the item.

    5) This process needs to be repeated for each item. It also needs to be used for multiple excel files (like a function; someone can select the first cell in the column and run the program regardless of the location of the column within the file).

    My biggest issue is getting the program to select a value from the first worksheet, classify it with the second worksheet, and write it back to the first worksheet -- then repeat the process all over again. I can't get the stupid thing to access the right worksheet at any given time!

    Any help would be appreciated!

    Thank you!!!

  2. #2
    VBAX Contributor
    Joined
    Jun 2007
    Posts
    150
    Location
    You are at the stage where you need to do a little studying. But a good reference book, and then read most of the articles on this board.

    If you are used to the way the macro recorder does things, learning to properly reference Excel objects is hard. For specific help referencing Worksheets, this is a great article:
    http://vbaexpress.com/forum/showthread.php?t=9771

    Once you've read that, take another crack at your tool, and then post a workbook for us. Without a workbook, its REALLY hard to visualize the problems you are having.


    Also, you probably don't want to hear this, but Access might be a better solution.

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi rklavon
    Welcome to VBAX.
    You can post your workbook using Manage Attachments in the Go Advanced reply section.
    Regards
    MD
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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