Excel Macro Utility for CE-QUAL-W2¶
This Excel macro was written by Jeffrey Gregory, P.E., Civil Engineer, U.S. Army Corps of Engineers (USACE) Nashville District, and updated by Scott Wells, Portland State University (PSU).
Overview¶
The Excel macro file w2tools_examples2.xlsm can be used to develop and write out input files for the CE-QUAL-W2 model. This utility is especially useful when the model user develops an Excel workbook with separate tabs for the different input files for the model.
Example Workflow¶
Consider the input file for wind sheltering using the free format (or comma-separated values [CSV]) formatting option. You can develop a workbook for this as shown below. The coloring in the workbook is optional and serves as a visual aid.
Using the Macro¶
- Open
w2tools_examples2.xlsmand enable macros. - After enabling macros, a new header labeled Add-Ins appears in the ribbon.
- Click the Add-Ins header to access the following options:
- Modify Selection - modify the highlighted data
- Export Selection - export the highlighted data to a file
- Run EXE - run an executable
Exporting Data¶
- Highlight the portion of the spreadsheet to export.
- Select Export Selection, then choose Any selection to csv format.
- The file is written as a free-format CSV file with the file name based on the worksheet name (e.g.,
wsc.npt).
Many other export file formats compatible with CE-QUAL-W2 are available. The worksheets in w2tools_examples.xlsm generally show how to use the different macro features. These sheets serve as examples of the Add-In macro usage.
Modifying Data¶
The macro tools also allow you to modify a selected range of cells by:
- Multiplying
- Adding
- Interpolating data gaps
- Rounding
- Transposing
To modify data:
- Select the area of the spreadsheet to modify.
- Select Add-Ins, then Modify Selection.
- Choose a tool, such as Interpolate (either the X column or the Y column of a two-column selection).