|
|
Subject:
Excel and Visual Basic HELP!
Category: Computers > Programming Asked by: boclegant-ga List Price: $50.00 |
Posted:
27 May 2005 13:51 PDT
Expires: 26 Jun 2005 13:51 PDT Question ID: 526440 |
|
There is no answer at this time. |
|
Subject:
Re: Excel and Visual Basic HELP!
From: manuka-ga on 29 May 2005 21:36 PDT |
Hi boclegant, You can assign code to any of your controls. So you can add code to your "Project Name" control so that when the value is changed, the other two controls are cleared and the appropriate set of values is loaded. The precise method of doing this depends on how you've created your controls. It sounds as if you've put them in from the Forms toolbar, in which case if you select the control (right-click it), the "Edit Code" icon on the Forms toolbar will be enabled. If you click on this VBA will open with a blank Sub (piece of code) to be run when the value of the control changes. If instead you've put them in from the Control Toolbox, make sure you're in Design Mode, right-click the control and select "View Code" from the pop-up menu. If you don't need the controls to be displayed all the time, or if you want to re-use the same set of controls on each worksheet, you may be better off putting them into a VBA UserForm. This is basically a customisable dialog box. Whether this is an advantage probably depends mostly on what behaviour you want when the user switches sheets. If you want settings retained separately for each sheet, given that you only have a few sheets you're probably better off with separate controls. If the user is likely to want to use the same project and account information on multiple sheets, a UserForm will be better. You can also hide the UserForm if you don't want it always displayed (though the downside is that you have to make sure you show it when you do want it visible). Controls in the same UserForm can also access each other without being visible to the rest of the application. On another note, depending on how many project / account combinations you have, it will likely be best to have this information stored in a separate part of the workbook (e.g. in a hidden sheet, so that it doesn't get inthe user's way). That way we can load the account information from the worksheet when the project changes, and when the list of allowed combinations changes we only have to make appropriate entries in the spreadsheet rather than editing the code. If you can post a comment clarifying the following items, I can respond in more detail about how exactly the code should go: - Do the controls need to be visible all the time? - Do you want the separate worksheets to maintain their own controls, or will it be better for the same settigns to be carried over when the worksheet changes? - Are the same project / account combinations to be available for all three worksheets? - How were your controls created (Forms, Toolbox, VBA)? Cheers, manuka-ga |
Subject:
Can simple lookups do it?
From: alesmith-ga on 30 May 2005 03:12 PDT |
Maybe I am oversimplifying, but this looks like a job for lookups. It would be easy to make the following flow: - user chooses an account description, perhaps from a drop-down list - account number is looked up and put in a cell - project name is looked up and put in a cell This would be done with simple cell formulas (not controls), using the VLOOKUP function. I am probably oversimplifying, but I do always try to bring Excel problems down to a simple solution (usually successfully). Cheers, -Dave |
Subject:
Re: Excel and Visual Basic HELP!
From: manuka-ga on 14 Jun 2005 20:55 PDT |
Hi Dave, That makes the job easier for the computer, but it's not a good flow from a human-factors perspective. It's much better for the user to be able to select the project and then choose from a list of account descriptions, rather than having to pick among several account descriptions which might be virtually or even exactly identical and hope they get the one associated with the correct project. (Of course if different projects do sometimes use the same account description it makes it significantly harder to do using lookups.) Boclegant-ga, I've been thinking about this (even if I haven't posted anything - sorry! been busy) and despite what you've said above I'm not convinced that separate controls is the best way to go. It depends whether it is more useful for you to have controls in a fixed cell on the worksheet (in which case separate controls is fine) or floating over whatever area of the worksheet you want to work in. In the latter case I'd recommend using a single VBA modeless form, but making it smart enough to update the available options whenever you change worksheets. This will prevent having to make multiple code changes any time it needs updating. I'm also thinking along the lines of maintaining the available choices in a separate, normally-hidden worksheet. Let me know your thoughts. I will try to post some more detailed comments and hopefully a simple prototype in the near future. Unfortunately I'm pretty much flat out at the moment. Cheers, manuka-ga |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |