PDA

View Full Version : Using a worksheet as a database



rklavon
07-29-2008, 05:42 AM
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! :banghead:

Any help would be appreciated!

Thank you!!!

Dr.K
07-29-2008, 05:48 AM
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.

mdmackillop
07-29-2008, 12:16 PM
Hi rklavon
Welcome to VBAX.
You can post your workbook using Manage Attachments in the Go Advanced reply section.
Regards
MD