Excel For Eng 02 PDF
Excel For Eng 02 PDF
1-Macros in Excel
2-User defined functions
3-Controls from form Toolbar
4-User form and controls
5-VBA (Visual Basic for Applications)
1
Record a macro Macros in Excel Record a macro Macros in Excel
2
Record another macro Macros in Excel Assign a macro to a command button Macros in Excel
Assign a macro to a command button Macros in Excel Assign a macro to a command button Macros in Excel
3
Assign a macro to a command button Macros in Excel Assign a macro to a command button Macros in Excel
Form controls
Form controls
4
Form controls
Form controls
Group box
Command
button
Combo Box
List Box
Check
Box
Scroll Bar
Option button
Excel for Engineers-part2 17 Excel for Engineers-part2 18
5
Form controls
InputBox Function
InputBox Function
Syntax
InputBox(prompt[, title] [, default] [, xpos] [, ypos] [, helpfile, context])
6
Input Box
Massage Box
Syntax
7
Creating user defined functions User defined functions User defined functions
y = a0 + a1 x + a2 x 2
Function myfun(x)
a0=5
a1=0.5
a2=0.75
myfun=a0+a1*x+a2*x^2
End function
Now you can go to the excel sheet and type =myfun(1) the
answer will be 6.25
Excel for Engineers-part2 31 Excel for Engineers-part2 32
8
User defined functions User defined functions
9
Example on creating functions
10
Steps to insert a module into a
Modules can be saved and worksheet
insert in new worksheet
1-In a new or current workbook go to Visual
Basic editior (Alt-F11)
Steps to export a module
2-Insert a new module
Go to visual basic editor
3-Click on the module with mouse right click
Choose the module to export select import file
With mouse right click select Export file 4-A pop up window will appear to select the
module you want to insert
Choose the prefer name and location to
save the module file [The extension of the 5-Choose the location and the name of the file
file will be *.bas]. It can be several (module) you want to insert
functions and modules
Excel for Engineers-part2 41 Excel for Engineers-part2 42
1-Table interpolation
2-Friction factor in pipes
3-Moist air properties
4-Thermodynamic properties
of water
11
1- Table interpolation
1- Table interpolation
Program name:
table interpolation.xls
12
1- Table interpolation
Water properties
Cp_water(T)
Prandtl_water(T)
Spvolliq_water(T)
Conductivity_water(T)
Excel for Engineers-part2 49 Excel for Engineers-part2 50
Laminar 64
flow Re<2300 f =
Re
Turbulent 1 ⎡e / D 2.51 ⎤
Re>=2300 = −2.0 log ⎢ + 0.5 ⎥
flow f 0. 5
⎣ 3.7 Re f ⎦
13
2- Friction factor for flow
inside pipes
3-Moist air properties
humidity ratio
Given two thermodynamic properties of air
along with total pressure, one then can find the h
rest of the properties W h Ws
f
For example Ws
*
dry temp. td t
14
3-Moist air properties
Some of the moist air properties relation
W = 0.622 Pv
P - Pv
*
Ws ( 2501 - 2.326 t * ) - (t - t * )
W=
(2501 + 1.86 t - 4.186 t * )
WP
Pvs ( t d ) =
0.622 + W
φ = Pv
Pvs
h = C pa * t + W (2501 + C pv * t ) = t + W (2501 + 1.86 * t )
File name:
Xsteam_excel_v2.6.xls
Site: http://www.x-eng.com
15
4-Water thermodynamic properties
4-Water thermodynamic properties
T
CP
Steam and water thermodynamic and P2 > P1
thermo-physical properties
P1
Sub-cooled region
Sub-cooled region
Saturated region Super heated region
Saturation region
Saturated vapor line
Superheated region
Saturated liquid line
s
Excel for Engineers-part2 61 Excel for Engineers-part2 62
16
4-Water thermodynamic properties 4-Water thermodynamic properties
1 bar=100 kPa
Excel for Engineers-part2 65 Excel for Engineers-part2 66
17
4-Water thermodynamic properties
ComboBox
Command
button
Label Tools
Forms, user Toolbox for
form1 Controls
18
Example: Simple Program
19
Excel for Engineers-part2 77 Excel for Engineers-part2 78
Summary
1-Cell Referencing (Relative & absolute) Conclusions & Recommendations
2-Introducing some of the built in functions &
Extend your use of Excel 1-Excel is handy, available and powerful
3-Use of Goal & Seek and Solver 2-Lots of help and examples from the net
4-Macros in Excel 3-It is highly recommended to extend you
5-Forms toolbox capability of using Excel for your courses
6-User defined functions 4-Learn how to use new functions, build your
own functions and form modules
7-Usful Engineering Applications
5-For full excel usefulness learn VBA
8-Userform and VBA
20
Excel for Engineers-part2 81 Excel for Engineers-part2 82
21