Question: In Excel, I want to be able to use a combo box (on another sheet) to display data from Sheet1 and then be able to edit that data and save the changes back to Sheet1. How can I do this? Answer: This can be done with macro code. Let's take a look at an example. Download Excel spreadsheet (as demonstrated below)
|
In our spreadsheet, our data is on Sheet1.
|
On Sheet2, we have our combo box which is linked to the data on Sheet1. When the user selects a customer in the combo box, the address and phone number will be automatically populated. The population of this data is done by a macro called PopulateData (which is the macro assigned to the combo box).
|
A user can then update the data on this sheet. In our example, we've changed Betty's address from 454 11th to 78 Granite St. Next, we click on the Save Changes button. This calls a macro called SaveChanges.
|
The macro will update the corresponding data on Sheet1 and display the message above when it has completed.
|
Now if we go to Sheet1, we can see that the address for Betty has been updated. You can press Alt-F11 to view the VBA code. Select the module called Module1 in the left window. Macro Code:The macro code looks like this: The macro code for the Save Changes button:
The macro code for the customer combo box:
|
Visit our busy book shop, were you can find latest books for beginners as well as advanced excel users.
Spreadsheet 123 Spreadsheet Software Development
See Spreadsheets for:
a.Hotel Management b.Personal Budget
c.Corporate Finance d.Rating Calculation e.Real Estate and Mortgage
f.Web Calc