+ Reply to Thread
Results 1 to 11 of 11

Excel Database Macro Help

  1. #1
    Registered User
    Join Date
    06-07-2011
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    5

    Excel Database Macro Help

    Hey everyone,

    I have an excel database that I have created with about 20 worksheets and over 45 macros. Each macro takes a section from one of the 20 worksheets and copies it to the main worksheet for an easy search function and user friendliness. I have a dropdown box with each of the 45 sections listed as selections.

    I need the coding/macro that will run a macro whenever something is chosen in that drop down box, and will run the appropriate macro. For instance, if someone chooses Accountability -Employee, I would like for the AccountabilityEmployee macro to run which would populate that page with the corresponding information and so on for all of the 45 macros.

    Obviously, I don't want you to give me the entire coding for the whole 45 macros, but if you can please just get me started, I would appreciate it.

    Thank you.

  2. #2
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Excel Database Macro Help

    Please Login or Register  to view this content.
    Is your code running too slowly?
    Does your workbook or database have a bunch of duplicate pieces of data?
    Have a look at this article to learn the best ways to set up your projects.
    It will save both time and effort in the long run!


    Dave

  3. #3
    Registered User
    Join Date
    06-07-2011
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Excel Database Macro Help

    Thank you for the start. Here is the code that I have:

    Code:

    Please Login or Register  to view this content.
    The cell on this spreadsheet that is housing the drop down box is C4,D4,E4 merged together. Where do I need to reference this cell in the coding?

    Thanks!
    Last edited by peachroses82; 06-07-2011 at 01:03 PM.

  4. #4
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Excel Database Macro Help

    Your post does not comply with Forum Rule 3: Use code tags when posting code. Please edit your post and add code tags. Once added, we can resume finding a solution for your problem.

  5. #5
    Registered User
    Join Date
    06-07-2011
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Excel Database Macro Help

    I'm sorry. I didn't know how to do code tags. I figured it out. It has been edited

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

    Re: Excel Database Macro Help

    Not really an Excel database, all data should be stored in one master sheet to be used as a database
    Hope that helps.

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

    Free DataBaseForm example

  7. #7
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Excel Database Macro Help

    While I'd agree most people throw around the term "Excel Database" too much, and it usually makes me cringe, I'm not sure I'd agree that all data has to be on one sheet for it to be a database. Relational Database concepts say that data should be normalized into different tables so as to minimize storing the same data in multiple places. I would think each Excel worksheet could be thought of as a "table" and the data could be joined together using indexes on a "main" sheet.

    Anyway, use the worksheet change event and test to see which cell has been changed like this:

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    06-07-2011
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Excel Database Macro Help

    Okay, here is what I have so far:

    Please Login or Register  to view this content.

    However, whenever I try to change the value in the drop down box, the VB debugger opens up with an error message saying "Compile Error: Method or data member not found"

    If I hit okay, the top line of code is highlighted yellow with an arrow and .ComboxBox in the third line of code is highlighted dark blue. I am really not sure what I did incorrectly. I copied and pasted.

  9. #9
    Forum Expert davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2010
    Posts
    1,884

    Re: Excel Database Macro Help

    You're not using a combobox, you're using Cell C4, so:

    Please Login or Register  to view this content.
    This should go in the code for the worksheet containing Cell C4.

  10. #10
    Registered User
    Join Date
    06-07-2011
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Excel Database Macro Help

    Fantastic!!!!!!!!!!!!!! It works. Thank you so much!!!

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

    Re: Excel Database Macro Help

    I agree with separate database sheets, e.g. I would have one for say Suppliers, one for Purchase etc. However, I don't think this is what the OP has

+ 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