Question: In Excel, I want to create a macro button that when clicked will replace all formulas in my spreadsheet. The tricky part is that I want the formulas to reference the data from a particular row in the spreadsheet - one that I specify. How can I do this? Answer: This can be done with a macro. Let's take a look at an example. Download Excel spreadsheet (as demonstrated below)
|
In our spreadsheet, we have two sheets called Form and Data. On the sheet called Data, we've placed information in rows 2 to 6. This will be the information referenced by all formulas in the spreadsheet.
|
The sheet called Form is where the formulas reside. Each cell with a red border contains a formula that references data on the Data sheet. We've placed a button on the Form sheet that when clicked will prompt for the row number that all formulas will reference.
|
In our example, we've chosen to have all formulas reference the data in row 3 on the Data sheet. The macro will then replace all formulas on the Form sheet. When it has completed, you will see the following message box appear:
|
Now when you return to the spreadsheet, you can see that all of the formulas now reference row 3 on the Data sheet.
|
To view the macro, press Alt-F11 and double-click on the module called Module1 in the left window. Macro Code:This macro code looks like this:
|
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