Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 20

i will post it in the chat room so if you have any all right so i see some of you say you

have to cheat right


that's good so let's continue with that so um the first actually i started doing some programming actually
in web design so my first website was done in 2003 at that time it was a very long time ago the most
advanced computer you have is windows xp and at that time 50 kilobytes per second is the fastest
internet speed you have and now it's very different so my first time i joined a website design
competition so you can see it's actually me right here and i joined the scouts research organized by the
malaysian scouts association and this was the first time i actually did some programming and
engineering which i which actually gave me the interest to continue studying in engineering so this guy
here is wayne he is now a software engineer in amazon in the united states so we have ended up pretty
far away from each other um i think most of you guys are university students probably maybe a few
lecturers and so on but just to share my easty life firstly i was very honoured to be invited to visit the
shell of soil platform of sabah i joined the national chemical engineering symposium i helped to develop
an app i launched a 24-hour hackertop international conference and some chinese literature
competition because i'm chinese yeah so the the one of the things that may be interested in what is iot
industry revolution 4.0 was everyone i was invited to launch this app called unichat you can find on
google play store and apple app store where we have about 10 000 downloads and it's actually an app
for unic students to connect with each other but unfortunately it's only available in malaysia maybe
we'll launch an indonesian version soon so what do i do now so i currently i'm working as a part-time
advisor for the regional chemical engineering undergraduate conference so it's basically a conference
for mostly final year students and i run a facebook group where i share things about chemical
engineering and industrial revolution 4.0 and i also usually post things on my linkedin profile about
python and vba so if you are interested you can look more after this session but let's come back to the
main topic today and ask what is microsoft excel so this is microsoft excel you probably know what's it
by now so i'll not talk too much about what is microsoft excel so it's a spreadsheet program developed
by microsoft it's a one of the reasons why bill gates is a millionaire today because uh microsoft excel is a
very obviously a very successful software and i believe most of you have this software so if you are not
using microsoft excel you are using open office some of these features might be different so i if you have
microsoft excel i recommend that you uh open it now so i'm going to show you a few things later on so a
few common myths before we start so this is a tv show mythbusters which i really like to watch all the
time and i'm going to show a few myths and i'll tell you why they are wrong so the first is that there's a
common perception that excel is only for accountants uh mathematicians and so on but the fact is that
engineers do use excel every day the next is a programming is only for computer science students but
the fact is that nowadays many engineers to use programming programming is only for nodes the fact is
as long as you know how to use a computer or phone which i'm sure all of you know you can be a
programmer and you need special software for programming it's difficult to learn not necessarily
because you can do programming in excel notepad and word etc so today we'll be focusing on excel but
perhaps if you have some more time you can talk about how you can do programming in microsoft word
how you can do programming using notepad it's actually very easy once you get used to it so i think by
now there are probably quite a few programming languages that we often hear about so we have
python and c plus plus these are the traditional so-called programming languages and spark are new
languages which are usually for data science and machine learning matlab and octave specialized
engineering software i think you use a magnet during your chemical engineering calculations i believe
java and javascript for app development html xml are for web design and technically they are not a real
programming language they are what we call a markup language which is a subset of the programming
so where's vba so you might be curious but from the name here vba you probably can guess where does
vba fit into the picture so vba is actually a type of a visual basic it's actually part of visual basic so visual
basic for applications is the full name it's diy from visual basic it's integrated into microsoft office apps
which is which means microsoft word excel powerpoint and access and all the other microsoft software
it allows for user defined functions so this is the strongest uh function of this uh visual basic and that's
what i'm going to show you later and if you have some programming background you might understand
that visual basic for applications is an object-oriented programming language i will not go too much into
this because it's quite uh complicated but just for your knowledge it is a type of a oop language and that
will decide how we can use it so an oop language means that the this programming language is very
strong and you can do a lot of things with it so when do we use vba so the first thing i want you to note
is that don't jump immediately into vba don't jump immediately into programming first it's better to
think if there are other ways that i can solve this problem without using programming so in excel we
have two tools the first is called gosi second is called solver and these two tools are very strong and in
many cases you can solve a lot of problems that you meet in your chemical engineering studies or even
in work like me so usually we use vba for repetitive complicated or iterative tasks for example i need to
calculate the same thing 100 times 1 000 times then i'm going to use a vba for these calculations so just
to show you what is go see so ghostly is under the what if analysis step here and what goes it does is
that go seek makes a equals to b by changing c so it's as easy as a b c just remember abc so these are the
terms abc that i'm going to use here so let's use the first example so i think most of you are chemical
engineering students right so i'm going to use a chemical engineering student example this guy steve is
taking five subjects this semester and he's worried that he might fail because his scores are not very
good obviously and he needs a average amount of 60 to pass so how many months does he need in this
final subject to pass this semester so if you are if you want to try you can take our calculator and start
pressing but i'm going to show you how to do in excel so let me open my excel now okay can everyone
see my worksheet which i have opened i think i think you guys can see so let's go to example one and
you can see that i have this return this year so what you can do is you can click on so this is the cell this
is the score that i want you to fill in which is a thermodynamic score so how do we use code secure is
quickly on data what if analysis goes in so this is the acoustic function so you can see the three you can
see the three items i need to fill in so the first is which cell to set so i'm going to set the average cell to a
value of 60 so i can just key in 60 here and by changing cell in here okay so you should get the current
answer of 75. so this is very simple example of what is closing so let me go back to my slides so this is a
result that you should get if you are using it correctly so what i did was i wanted to make these average
marks to 60 by changing the thermodynamic score so if you have any questions do feel free to type in
the chat box i'll address them later if you have any trouble using go see but if you don't have any
questions i'm going to go into my chemical engineering example of ghosting so i'm going to use a simple
quench system design for uh to show you how ghostly works in chemical engineering so this will be a
mass and energy balance calculation so uh this is a photo of a gas turbine a gas turbine is used to
generate power and many big actual chemical plants refineries use them so in this case this is actually a
real gas turbine supplied to the pertamina papaya finary project which is a very big project in bulunil i
believe and so what happens against turbines is that they produce flue gas flue gas contains co2 h2o uh
carbon monoxide co and no2 no so co and no2 uh co and no and no2 are dangerous gases and so that
usually gas turbine outlet will have some kind of reactor to reduce these two emissions to a very low
level before they are charged through the stack so we have few guests entering two here and because
the temperature of flue gas is high usually we have some quench air injection so this is by absorbing air
from the atmosphere we mix the air into the flue gas temperature goes down goes into the reactor and
out the step so this is a simple uh quench system design for gas turbine so i'm going to say so let's say
we have an example so steve again uh this you are going to see this guy a lot of times today he's
designing a quench system and the plant manager wants that the flu gets to have 15 oxygen malfunction
so now we want to know how much air is needed to make the fresh air to turn the fuel gas into 15
percent oxygen so we are going to have some compositions here and fresh air is used with this
composition find the mass flow rate of fresh air required so let me go to the excel here and we are going
to go in the example too so you can see that i fill in the calculations here if you don't have i'm going to
just show it for to you how to fill in so i made a table of what are components in flue gas o2 n2 co2 i
have um mole fractions here and i have the total flow rate so the first thing first of course i'm going to
calculate the average molecular weight and then the molar flow rate here and now i'm going to just
multiply by the purple fluid and for here i'm going to calculate using the i'm going to calculate the mass
for weight of which component oops i forgot the t right 100 so let's see so i have not gone through too
much of the theory of how to get an old-fashioned mess fashion and so on i hope you guys know how to
get this but if you have a problem with uh this to type in the chat box i address them later so you can
see that i've also made a table for fresh air and the value receivable here and we have the flue gas and
fresh air mixture which i and actually i just added up the two uh flow weights so for nitrogen i just added
up these two fluids and carbon dioxide i added this fluid because we don't have carbon dioxide in fresh
air and we i get the total here and i calculated of course the the mole fractions and mass fractions in this
case so i don't want to go too much into theory just to show you how this works i'm going to use goal
seek to make this 15 percent so again go to what if analysis goes seek so i set this cell like this select the
value of 15 and by changing cell i'm going to click here so the mass flow rate of fresh air i'm going to
change it so i just hit okay oops so i finally got the answer here so this is a simple example of goal seek
let me see if i have any questions uh can we get a presentation later the presentation is in the in the link
that i just posted you can download the presentation from the link so don't worry you can just download
the presentation from the link all right so again this is a b c and i make final o2 content 15 by changing
fresh air flow right actually get the answer here and i'm going to go to the next uh i go which is solver so
solo is the big brother to go see however solver is used for optimization problems and it's quite difficult
to use because you must define the problem in a way that contains these three parts the objective
function inequality constraint and equality constraint so very complicated right so let me show you a
simple example let's uh have steve again he is now working at a refinery and he's trying to blend few to
meet certain specifications so i'm going to show you these specifications minimize cost the wrong
number more than 95 lakh content less than 0.5 density more than 750 so determine the volume
fraction of which field required so before i start i'm going to assume that all the properties are going to
be linearly proportional so for example the cos is just a volume fashion the course add the volume
fashion multiply the cos add the william fashion multiplier cost and then i total the whole thing i can get
the course so this is an assumption of course the solver will work if there's no assumption but i'm going
to use this just to make it a very simple example so note that x y x directories will end up 100 because
this is saturated with fraction so let me show you in excel because it's quite difficult to see in the slide
here so let me go back to my excel here and i go to example three okay so you can see i have the
problem here i have helped you to make the calculations as well so it's much easier to see from here so
what i'm going to do is i'm going to click on forward just beside the what-if analysis so one question you
have is that but i don't have this solver how many of you you do not have this icon in your excel i'm sure
many of you do not have this right so what you do is you click on file options add-ins manage access
links you'll click go and he'll make sure that you take solver and click ok then solver should appear under
the data tab analyze solver so i'll say it again click on file options add-ins so make sure that you have
take this okay then you shall see software in the box here so you might have a different version of excel
then some of the steps will be slightly different but they will be generally in the same place if you have
some trouble please type in the chat box if you cannot find race for someone okay so i'm going to use
forward now i'm assuming that you guys have solver so i'm going to click on solver oops see them
iphone from here let me try another version of this okay so let me try this so i already have the answer
here unfortunately so let me delete the answer okay let's not show the answer and i'm going to use
software right now so let me go to that now solo so you can see i fill in here but just to uh just to delete
these settings i'm going to click set all okay so no more so let me guide you one by one so the first thing
is the objective function so this is what you want to maximize what you want or you want to minimize or
you want to set to certain value so i want to minimize the cost so i'm going to click here minimize select
fill cost okay the next one is the variable cell so this is what i'm supposed to change so i'm going to click
this i highlight the three components subject to the constraints so these are the constraints i've written
here actually so let me click on however so i'm going to click this one more than and five then click on
add then click this s then things 0.5 3 more than 750 and the total volume should be equal to 100 so you
can choose to type here or you can choose to select yourself so i'm going to do both just to show that it
can be done okay and i'm going to make unconscious i'm going to take this one make unconstrained
variables in that it means that these variables that i just chose here that means the three volume
fractions are going to be not negative because i don't want the rolling fashion to be negative otherwise
it would give me a negative answer and then click solve and my magic you'll get the answer so in this
case solver thinks that i need to blend 49 42.9 percent of a it is not b so that's the best solution that
minimizes the cost of the field so let me go back to my slides here so i'm going to show you in question
form and so objective function is to minimize cos inequality constraints and equality constraint and this
x one more than zero s two more than zero x three more than zero is to make sure that it's not a
negative number and i do that by just taking to stick the box here and it will settle this constraint for me
so if any questions please type in the chat box i'm going to look at them later and you should get the
same answer as me so if you're lucky it does take a bit of luck sometimes so if you cannot get the this
answer you might want to change these values for example i put in like 40 60. what this i'm starting
value that's close to the final answer and then you try to use solver again you should get the core
answer if you use it correctly yeah any questions this time in the chat box i have a look on the questions
so i have shown you the how to use ghosting how to use solver but there are some problems that i
cannot solve with both gosi or solver that's the problem so in that case i'm the first for example one
major problem that i cannot solve would be how to do the value so you can energy balancing excel but if
you want to type out it's a lot of equations that and it's very complicated to do so so i'm going to show
you how to use vba in microsoft excel so let me go back to my excel here okay so the first thing to do to
open this vba is to click on developer which is your basic so this is how you open it so the first question is
i don't have this developer tab i'm sure some of you will not have it so what you do is you click on file
again options customize ribbon here you can choose popular commands so i think you choose main tabs
here click on developer and click add so i've already added so i'm not going to add again but this is how
you add the developer tab into your excel so you just hit ok so this developer tab should show up so let
me just click on visual basic okay so i have so i have the um so this is a simple visual basic so let me open
my blank one just show you so this is how the visual basic editor looks like so you're going to do your
programming here and it's a very powerful tool that you can do a lot of things here so i'm going to show
you uh a few things first is this project this is the project window where it shows you what is open right
now so i have two excel files open let me close this file file let's not save it so now there's only one left
but this is uh it shows you which files are open and inside this file you should have a sheet of which
example is which one and but usually i would not do it like this way i actually i click insert a module so
this module is a place where i can store my code and it's better because i can access this code anywhere
inside the excel file for example i have 10 cheats i can access this module from all the 10 sheets if i put
the code inside this sheet one i can only access the code in sheet one so it's quite difficult so i'm going to
click on here insert module so i have this movie one so when i click this this property window will show
up and then i can give it a name let's just call it uh oh there's a sample name here so this is a general
window where i'm going to type in what code i want this is the immediate window which is a i can run
code immediately in this window and this is locals which i'm going to show later so if you don't have the
same window as mine click on view you can access all the windows here for example i can click on locals
and you will show this focus window yeah so this is the basics of vba so let me go back to the slide so
you should see this screen it's the same as what i've shown this now and so before we start coding we
have to understand the basic components of vba so there are following to be four components the first
is variables so a variable is where a container where i used to store information for example i can use a
variable i can store my name widget and that's a variable after i have stored this information inside i can
manipulate them using operators so i can add minus divide multiply and so on after i have defined these
two i need to define the function which is what i want to do using the vpa code finally i need to decide
when to do what and how many times to do something so this is uh branches and loops so don't worry it
sounds a lot to you but i'm going to guide you step by step on how to use these four main components
so the first is our variables so there is a very large number of variables there are i think at least 30. but to
be honest we are not going to use 30 we are going to use like three or four so there are a few types of
variables these names are going to be uh specific to vba and i give you an example so a string it means
some words or text so hello world exclamation mark it's a string integer is a number can be positive
negative or zero boolean means true or false which is used in logical applications in computer science
we have single which is a type of which is a number so double is also a number so the difference in these
two numbers is the accuracy so double is a more accurate version so in single is actually if you round off
your number to a certain decimal numbers in order to save memory space so if you want to be perfectly
accurate you want to be more accurate just double and we have the variant data type so variant type is
actually if i'm not sure whether i won't need to play a number or text i can put in variant and array is a
collection element this is a more advanced version so i'm not going to talk about it today and empty
means there's nothing so in excel you must understand that in programming and actually many other
languages zero is different from emp stopping this shoulder variable show the variable so in this case i
just defined sequence 2 so 29 is going to show 2. so you can go to the next line let's say x equals to 2
plus 4 between x right it's going to show x equals to 6. so it's very simple here so let me let's say i define
y equals to 3 uh set equal to x window i got nine now hopefully no problem this so let's try some string
uh string terms so let's say my name i'm going to call this variable my name i just show you why we
name variables we are going to use capital letters site just to make it easier to read if i do it like that it's
okay but it's more difficult to see so i'm going to read this and i'm going to put my name in the in quotes
and then print my name so i get my name up so this is how we use variables and then let's show you a
boolean variable let's say uh a equals to two the point a financial two so the later i'm going to show you
how you uh how you are going to use this but you can see that uh this is what you call a true false
variable or boolean variable and let's say if i try to type in something that i haven't defined let's say b
nothing happened because this is an empty variable yeah so this is a simple introduction to how you
type things in vpa so but having only variables is a very boring because you can't do anything with it so
next thing will be operators so operators are how we manipulate variables to get what we want so we
can have simple mathematical operations exponent assignment assignment means i want x equal to
something this is a not equal to something less than greater than less than or equal to greater than or
equal to can all and not so i'm going to show i just saw i think plus just now so i'm going to show a few of
the bottom ones here so let me go back to this maybe i'm going to delete all this just to make it easier to
see and let me say let's say x equals to 2. now i can use a comparison let's say i can print x equals to 2.
we say true because s is equal to two so let's say print x equals to four first because x is not equal to four
green x is not equal to two it's a false because x is equal to two so some of these logic can get a bit
confusing so i can also do some very complicated uh let's just say and let me give you y equals 1 when x
equals to 2 and y equal to 1 so because both of these are true so let's say i change y to 2 between x plus
2 and y equals to 1 i'm going to show false between x equals to 2 or y equals to 1 and they show true so
n so definition n is that if one of them is if both of them must be 2 then they'll be true for all if one of
them is true then the answer is true so this is this is a simple example of operators so if any questions
this time in the chat box i'll try to answer them later so let me go back to this slide here so you can so let
me show you this last one no i can print x not uh i cannot print not true let's say when you say false so
this is a simple way of using more well next thing i'm going to show you is functions and sub routines so
this is okay so this is the main function of how to use vba we have function and subroutine so a function
is something that has input and output can be called so subroutine is something that has only input no
output can be run so sounds very confusing right don't worry later i'll show you can be private or fiber so
these two things are decide how you can access that it's recommended to declare all variables before
use uh just to make sure that it doesn't have any problems in the code so let me just show you one
example of how to do a function here okay so i'm going to teach everything here i'm going to go into this
going to click on my testing module and i'm going to use this so i'm doing clear everything here first and
how do i define a function is i just type in the word function and then i give it a name let's say press one
close packet so this is the way to define it when i press enter you'll see excel at this line and function so
that means that xl has detected the function correctly so let me just delete this and put in the sub
between retirement suv fine so same thing happens so i'm going to just to show you how to use this
properly so let me define a variable use the keyword to define a variable i'm going to call let's say
greeting s string so we've seen that i want this greeting to be a string variable and i'm going to assign the
sprinkler i'm going to call it hello and i'm going to ask it to report hello so i can use the message box so
this is a special function in excel where you show you a box that says hello so when you type in a special
function it's going to tell you a hint on how to use this properly so in this case i'm just going to use
greeting and i click run you can see the run sub user form button here i just click it and it shows the box
that says hello yeah that's it let's see i don't want to use this message box i can comment it on so by
typing a single point so this is a comment so a command will not be executed by excel so in this case i
can just leave it there just in case i want to use it back but currently i want to turn it off so usually i will
do is i will put this symbol and it will not run the code that i want i don't want it to run okay so this is a
simple example so you can try out this example in the slide here just if you want to uh just to play
around and then let's go to the more important things here which is uh how to use this code so after i
have a function usually i'm going to use punching and doping inside the function so i can do either
conditional bunching or loops so conditional bunching means if else so let's say i have if if something is
something i want to do something otherwise i do something else otherwise i do something else so this if
else first for loops is i want to do something a certain number of times so let me let me just try this
simple loop here okay so let me just delete everything here let's say do i as integer i'm going to use i as
an integer and i'm going to use a loop for i let's see what example here okay i have one two ten so i'm
going to use one two and i want you to show me one i want i want myself to tell me one two three four
five six seven eight nine ten simple as that so i'm going to use the keyword rebar.3 and then next so
usually what i will do is i will actually type in i will just put in a tab here just to show that which uh
functions are part of which part so in this case the block point inside this form so i'm going to uh do this
dabbing so it's in the show clearer and i'm going to just click one can you tell me my cool name that's
one because my name here i define as this one so it shows me test one click run so you can see the
immediate window will just tell me one two three four five six seven ten simple as that yeah so so if any
questions please type in the chat box i'll answer them okay so this one if else will be shown later
because it's more complicated so just to give a simple introduction let's play a game have you guys seen
this kind of motivational quotas before and it says uh if you want to get 100 you have to have certain
skills or knowledge for hard work but finally the answer is attitude so this is answer that we want to get
so can we do some excel programming to help me calculate the score for each word and then we can
find out which one we get 100. yeah so but before we jump into vba it's better to make a sketch of what
we want to do so let's say i have the word attitude so what i want to do is i want to separate out the
letters to individual and then i want to give the score of each individual letter and i i add up the score
and i just want the final answer 100. so this is a sketch so it's usually better before you start doing
anything you write down a piece of paper just to get a rough framework of what you want to do so let's
let's do this yeah so let me go back to this one and let me tell you everything so let me go back to excel
and you can see example four here i have prepared the sheet for you so you might need to do is you
want to calculate the score inside this box yeah just inside this box so let me just uh see if there are any
questions here no questions i'm going to proceed okay so i'm going to use for my call function because i
have input the output so in this case i get the input is this word this is the input i want the score output
so i have input output this is a function so i use the keyword function i'm going to call it let's say um
word score circles record enter so i get a new function sorry let's make some space here and i want to
take this word attitude inside vba so let me define a word as string but in this case because i have an
input this word is going to be the input for the function what i'm going to do is i'm going to copy this i'm
going to put this inside these brackets so this bracket means the input of the function so i want to use
word as an input so output is a score so i'm going to put score as an increasion okay and then i'm going
to calculate the score so i will initialize the score by putting a zero which is the initial score i want the
final score so to set the finance score i must give the score to this name so this is the output so i'm going
to have output red score first to score so i'm going to calculate the score here and then i'm going to put
inside this call and then it will show up in the excel sheet yeah so let me uh let me start to divide the
letters so to do the letters i need to have a variable so let me have a pin carbon letter as a string because
a vector is a text so i need to define as a string and i'm going to let's say use one letter i as an integer just
to show just to store the what is the current letter yeah so let me have a comment here the word we are
going to use this attitude just for my reference and i can see that this one has a 1 2 3 4 5 6 it happens so
that means that i'm going to use a four loop i equals to one okay so eight letters here and for each letter
i'm going to take out the score so i'm going to take out the letter first so i'm going to use a special
keyword here right such a keyword here is me so big means take out the letter that is currently at this
position so i'm going backward so it's going to show me the hin string start as long length so the first is
the what robot i want to pick up the second is what is the prediction so i and length means how many
words how many letters i want to take out so i just want to pick up one letter so i just type one okay
before i continue i usually put something to what i call a debug program so i'm going to just put me back
queen our letter just to make sure that the function is going to run properly so let me just change it back
to stop so i can run it here so i'm going to ends up here right quick one so let me use this spot as a
testing and then i'm going to shut down this current letter here just just for testing purposes and i'm
going to create one first function okay at this time of course next so let me try next here then should
work now okay so you can see that excel has successfully taken out the letter so that's a good thing so
let's uh continue with i want to change this uh letter into a number so a equals to 1 b goes to c equal to
3 d equal to 4 and so on so let let me just comment out this line and i'm going to change it to a number
so the way to do is to use a asc letter so just to see what shows up let me just put a default point
statement here finally i have double breakers because i have a function inside a function so let me just
delete this part and i click run okay something wrong here a is 65 point a to b one right what is a65 i
have no idea let's see let me just try the word b let's put a b c d e f g h like this so i guess sixty five sixty
six is seven six eight sixty nine seventy seventy one seventy two there's something wrong right i want a
to be 1 b equal to 2 c equal to 3 d equal to 4 equal to 5 and so on so then i can find other ways to do it
but the easiest way is just i will go to minus 64 from here because i know it's only in sequence right click
one before you show me the correct sequence yeah so let me just uh put back the word dipping delete
this copy so you can see okay finally i have managed to get the correct answer i want so i'm going to do
something which is i'm going to add up the score let me just comment out here i want the score to be
added so let's say i want let's say a score will start at zero i want to add one so it become one at 20
become 21 at 20 becomes 41 so i can do this by typing school equals score plus this part now i'm going
to just debug print scroll so when i type this you see you have scroll on both sides right which means the
new scroll is equal to o score plus something yeah so new score equals to o score plus something so i'm
going to just debug point here to make sure that it gets the answer that i want so let me just click right
okay so i can answer 100. so that's the answer that one so it shows that this code works properly so i'm
going to delete this i'm going to comment on this line because i actually don't need it and i'm going to
put back this and i'm going to put back this as a function okay so now we have the actual function here
so let me just save it just in case it crashes so when you save it you must be careful [Music] when you
save the file make sure that in the file type to put excel markup enable workbook otherwise if you don't
do that when you save everything all your code will disappear and then you are going to cry for the
whole day i can tell you so remember to set your save as this type excel markup enable workbook then
click on save and then only then will your code be saved inside the excel otherwise your excel your code
will be disappear yeah so better be careful on that so let me just try if this code works inside excel so let
me go back to my excel so how i'm going to call this function is i'm going to type in equal and use it as
any normal excel function so let's say i just type inward score you can see that sword scroll actually
appears as a custom function so this is what i call the user defined function that i said previously so i'm
going to open the record here i'm going to choose this cell so you just use it as any normal excel function
plus minus and so on and click on enter then you can get the answer yeah so so you can treat it as a
normal you can copy the formula you can break the formula with few and you can get the score so you
can see that these two answers are not correct so why so i'm going to teach you a little bit on debugging
so let me just go back and see why knowledge is not giving me the thing which means that it's not a
current answer let me go back to excel so what's the problem here the problem is that i set the the
length of the letter to be eight but knowledge actually has one two three four five six eight nine
knowledge has nine letters so just to make it flexible i don't want to keep changing the code i'm going to
just start inland l e n put so this will tell me the length of the word i'm going to save this and let's try if
you see it works so when i change the code it will not update automatically you have to like enter here
so it tells me the query answer now so knowledge is 96 and let's try this which balance 59 so we have
completed example four yeah so you have any problems please type in the chat box now i'm going to
leave this code up just to let you see if it gives you any problems you can follow and type in or you can
take a screenshot or you can take or use your phone and take a photo or something it's okay and we'll
just leave it here for you to have a look in case there are any problems if you have any problems please
stop in the chat box just to and i'll try to answer them so i see running problems in the chat box okay
there are some previous questions what's the difference between debug twin and queen so just now
when i show you i use the thumb queen hello but here i use the term debug print so what's the
difference between these two the simple answer that debug print is the correct method this point is a
shortcut that only works here if you try to use print inside it won't work yeah that's why for example i
can just start meaning debugging hello so it's going to show the same thing but when you're typing the
real code you have to use debug you can't just type queen let me save this okay i see that there are no
questions for now so if there are no questions i'm going to go into the next slide which is uh some
thinking problems yeah so the function only works up case words if you notice right the functional
numbers are per case words so what about lower case words so if i'll give you 30 seconds start making
your suggestion on how you are going to change the function so that invoice on both uppercase and
lowercase words any suggestions please type in the checkbox and i have look now how the hardware
make the function look on upper case and lower case words okay any suggestions um let's go back to
excel and let's reinstall a bit on how to do this so we can see that this word is must be a capital letter
word so let's say i i use the small letters answer 407 which is obviously 356 which is obviously not
correct so the problem is in vbai upper and case letter is different it's considered as a different thing so if
i put black i get 100 if i put the mixture of okay also a different score so this shows that in vba i consider
upper and lower case letter different things so how do i make this uh how to ensure that you can
calculate the score even if the i'm using output or lowercase so some people previously they told me
you can use an if else so if uppercase you do something else you do something but the easy way the
easy way is just to edit this part and type in the function upper the function upper what does this do is
that coupler will make the world uppercase that's all i don't care what the word previously i want to
break it up with this so i'm going to save it and show you what happens oops no different sorry sorry i
use the wrong keyword here it should be you the would word is to make the word uppercase so that's it
oops and click on stop debugging reset here and then click on try let me just uh do it outside maybe
better let me just u equal to u case oh yeah regulating uk sorry i forgot it so case is a major uppercase so
i'm going to just change this to keyword and then i'm going to type in new word here so let me click on
reset and i'm going to save it and then let me go back and see if it blows up so let me go ahead and so
correct it shows me the current so now so let me try a small letter so it shows me the same answer so i
thinking graphical letter same answer small and big letter and smaller same answer so this is how you
make something so that it's more flexible sometimes you have to think about how you can use the dba
properly sometimes some people let's say i make this code i send it to you you might not use the same
way as me so you have to build in some flexibility in how you can interpret the input for this vehicle
yeah so i hope your hope is pretty interesting for you guys so let me go back to my slides now and i'm
going to i'm going to continue with the more difficult example of mass balance it will take a while so if
any problems please type in the chat box now i'm going to solve the problem for you before we
continue yeah let me see the chat box you have any problems uh it's the link presentation link share yes
if the link is shared previously i'm going to share the link again just to just to help make it easy for you so
you can download the presentation slide and the worksheet from the link so i just share in the trend box
so you might want to download it now because the next example is more difficult so yeah so any more
questions please type in the chat box and i will try to answer them okay i see i don't have any questions
so let me just continue for a while so the example number two is going to be energy balance so this
topic is a little bit about mass and energy balance so just now i show you some mass balance so maybe
now i'll just show you an energy balance example and for energy balance one of the more important
concept is a heat capacity so i think you'll know what heat capacity is just but just to refresh your
memory the definition of heat capacity is the heat energy uh required to raise the temperature of one
more substance by one degree celsius so in this case i use the mole definition so in in many textbooks
for example in berries chemical engineering handbook the heat capacity is given as a formula a plus b t
plus c d squared and so on and the constants a b and c are constants they depend on the substance so in
this case then let me just show you an example using oxygen nitrogen and carbon dioxide just simple
guesses for now so just for refresh from memory a bit if you have studied this before if not then i'll just
give you the consensus so you don't have to go and look in the paris chemical engineering handbook so
the actual equation has more terms so some have a plus d plus e plus f plus g but for this example i'm
just going to use a simple version you only have three constant a b and c the actual term actual just to
tell you this is not actual answer don't be too don't jump and think that this is a correct capacity no
because it's the real one has many more terms d e f and so on so i give you the cp heat capacity in gel
per mole celsius abc are constant depend on gas t is absolute temperature in kelvin to convert from
celsius to kelvin i'm going to this probably i hope you notice that you just add 273 or 273.15 is okay i'm
just going to use this to be simpler and i'm going to tell you how to develop a function cp with the input
substance and temperature so substance will be the name of the gas so i'm going to put new substance
here and the temperature is going to be in degree celsius so let me just go to my excel a little bit so what
i'm going to do is i'm going to give you a cp i'm going to develop a function where i can type in like o2
and then the temperature let's say 100 degrees celsius so i'm going to develop this function now there's
no answer because uh i haven't actually done it yet so i'm going to develop this function for you let me
go back and do this actually so i'm guessing just not to disturb this i'm going to right click here insert
module so i'm going to insert the new module this module let's say i just call it uh example 5. okay
simple so just delete this so i'm going to call this a function cp record substance string e degree c s uh
double so i can also use it as single but the difference between single and double is that the single is a
single precision floating point number so double is going to be double position floating point number
well the simple explanation is that the temple is more accurate just to not go too much into computer
science because i'm not a computer science scientist myself i'm a chemical engineer also so i'm just
going to tell you that double is more accurate so i'm just going to put in double in this part right and let
me just look at my cheat sheet a bit okay so i'm going to introduce a four brother answer i'm going to
introduce a formula for heat capacity so i want the heat capacity to be the output so this is output i
must calculate the output here so i'm going to put cp equals to a plus b multiply b remember that you
have to use the multiply symbol i cannot just type in bt it will not work properly and i just add c multiply
b power 2. so to be safe i'm going to put this in bracket but it will also work if this is not impacted i'm
just going to be safe here and now i need to define the terms of course a b t and c let me beam b as
rubber so a b and c are constant so i can just start in this way a b and c s double this is sorry function
may not be the word n so this is a shortcut so i don't have to keep wrapping the same thing again and
again and again i can just put all together the same line with uh commas so that's a simple way so let me
just uh do the first one so let's say for oxygen i'm going to type in a equals to b equals to c percent then
i'm going to just copy them from the sheet because i'm a bit lazy to tell everything so let me just come in
here i would copy this number okay why not have the numbers here so and then the final thing i will do
is i have to get the t so the d is a temperature in kelvin so to get kelvin i have to mount at 273 to the
answer so in this case i should get the correct answer for oxygen so let me just uh try and see if it works
you think something here let me see why i'm missing sorry i should have put minus maybe you can
check the word strong to be replaced by string yeah true i think there's a typo thanks for telling me how
it's okay so let me just try and see if we work properly okay so i gotta answer you probably is not
working properly so this one should be done so so i have shown you how you can use this uh i can just
type in directly or i can refer to the cell so i can just refer like this and this i can refer like this to give me
the safe answer so this is how i can use a function so you can imagine that you can deal with a function
for enthalpy density viscosity uh compressibility vector thermal conductivity and so on so you can
imagine that as long as you have a constant you have the equation you can do a lot of functions that you
can think of what you can think of you can do it and even in thermodynamics also so we have developed
the first one for o2 if i try to drag this it will also calculate the template the cp for o2 because i haven't
changed it right so in this case only o2 is uh is defined so let me just define the variable for if i'm going to
change it to nitrogen i'm just going to change this tool and i'm going to copy the consonants here
because i'm lazy without them okay so now i have these two gases i need to have a way to switch
between oxygen and hydrogen otherwise it would not work properly right it would just give me the
value for oxygen so what i'm going to do now is i'm going to use what we call an if statement so i'm
going to okay if open bracket substance is actually occlusion then and then you will uh lower this feed so
let me just put this in proper place okay if i want to go i will go to nitrogen so i can just type in substance
equals to n2 okay so let me just put this in the right place and i can do one more for carbon dioxide later
so but but remember that if you have an if and else i must have a and if just to make sure that the whole
thing is properly uh done so i'm going to probably just i'm going to make using embed first to see
properly so now let's see if it works out let me just save the project okay so now it works properly so it
gives me the heat capacity of nitrogen uh heat capacity oxygen probably is not showing properly but so
the first one for co2 so let me just put mean for co2 so let's if i add a new co2 i can just copy this part
and to this i give this command for carbon dioxide co2 and i'm going to scale the constants from the
sheet so just as a just a simple inside if you must have uh one one if only one if for else if you can have
as many as you want you can have one two three ten twenty hundred or zero and if you don't if you
have a last one you can actually just start else so in this case for example i only have three guesses the
last five i can just start else then it will work so i can just comment out this one and i can use stuff else
and if it's o2 will it will choose this and two you choose this else it will choose this it doesn't care what
what anymore any other guesses that you have but just to be on the safe side i'm going to not use this
term else i'm going to use else if because i can use as many lcs as i want and remember to put in the end
statement here just to carry when you stop meant to stop choosing so let me just try in the last one so
let me just drag retail or i get the value error because this is actually a string 300 space k is not a number
it's a string so but i want the temperature to be in 300 kelvin i don't want it to be in celsius so what i do
is i can just click on here change the temperature input to minus 270 yeah so i get the answer oh i if i
want i can just do it here so i get the temperature in celsius and then i just respect temperature so i can
get the same answer so this is probably everything that i'm going to show you today for cleat capacity so
you can think of many other ways that you can do anything so but the strong thing about this kind of
functions is that you can manipulate them just like any other excel function let me just look at this task 3
calculate the cp of a mixture of two gases so i have these two gases i want to calculate the cp of this
mixture so what i can do is that i can actually just up enter cp and i can just use this multiply or be right
just like any other excel function so i can just multiply that i can treat this right i can treat this part like
any other normal standard excel functions that i can add it's multiplied by cp and 2 temperature and
then the whole thing is so i can now rocket the ct for simple mutual gases of course i'm assuming i do
guess here in real life the cp is not just an addition and i can get the correct answer so this is a how we
can manipulate these functions by just uh by just using them as any standard excel function multiply the
y and so on so if you have one as far challenge you're going to see that between this there are some
hidden rows here you can hide the rules where i have given you some extra uh questions that you can
try if you want to know more about vba but they are more difficult until i throw a few chilies the more
number of chilies means are more difficult so like last one is very difficult second is medium difficulty
first one is probably easy so let me go through with this with you write a function cp average that
calculates the average of cp at two temperatures so if you want to calculate the average of cp at two
temperature i can just let's say i have temperature uh 100 let me just put this under here unload 25 and
i can just i mean cp or 2 let's say o2 100 plus cp and then i can just pivot by two so this is the answer is
there a better way to do it easier let's go back to my vpa here and what i'm going to do is i'm going to
use the same module i'm going to define a new function below this module so i'm going to create a
function cp average you can see that excel actually adds a new line between these two different
functions and so inside this function i'm going to calculate the substance of course s3 and we have a
temperature one as a double and we have temperature two so so what i can do now is i can copy this
whole code again inside this new function let me just track this a bit so i can copy this new code into this
function and i can calculate the same thing but it's difficult and it's very annoying because i have to have
very long code so what i can do is i can just ask excel to go back to this function calculate this value and
then come back here so this is a shortcut so i'm going to say cp1 let's say bin cp1 cp2 as double let's say
cp1 equals to so i can call another function here substance p that's 0 and cp2 equals to cp substance
with cp so what happens now is i want excel to save inside cp1 go into cp give it the same substance give
it temperature degree celsius one take out the answer save here and do it again but with a different
temperature so it's possible to do this and this is what we call modular programming that means i write
my code in a way that it has one module second model will refer to the first module so when i change
the first module the second module will change automatically so that makes it very easy for
programming so i don't have to keep repeating the same thing again and again and again because it's
very tiring so i'm going to calculate cp average here equals to cp1 plus cp2 v1 by 2. s5 if it works up let
me just save this and go back to this cp so you can see the new code national cp average i'm going to
type in o2 temperature 1 temperature 2 so i get the same answer so this is how you use functions inside
other functions so the correct computer size term is a recall we call these uh nested functions so the
collection is actually called nested functions but i'm just going to use too many difficult terms here so if
you have any questions please stop in the chat box i'm going to just show this on the screen just in case
you're any trouble um i think it's small so i'm going to show you this on the screen so if any trouble you
can have a look on how i do that and if any questions please type in the chat box and i will try to answer
them let me see the sandbox now it has a question from miss julian dewey why we do not directly just
calculate cp using functional worksheet instead of using vba okay very good question and this comes
back to let's say how you want to use this cheat capacity for example um let's say i have 10 different
watches inside my excel file like when i'm doing a real project in industry we use excel we have 10 20
sheets and every sheet we have to calculate the heat capacity of some gases that are similar let's say
co2 water oxygen nitrogen so all the 20 issues will have the same gas to be calculated so the problem is
that if i want to do heat capacity inside excel i have to copy paste inside every sheet or have to lean the
formula across sheets and that's very uh inconvenient for you you have to keep copying the same thing
again again very long and so on but if i do in vba i just do it once i do it once i can go to excel i can access
the code from any sheet i have 100 sheets 50 sheets 20 sheets doesn't matter i can just access it directly
and this also means that i can access it i can use the cp value for certain other calculations for example i
want to calculate the heat enthalpy i can write an enthalpy function in vba that uses this vbacp value so
it's actually very easy because once the code is there i can refer to this code from other bits of code so
this one makes it very convenient and actually just to be just to share with you i use this code every day
in my actual working life yeah so i'm not just sharing something that is in theory so my company and i
we use this sort of code in corporations every day because sometimes like even you have process
simulator and so on like sperm plus or isis some things is better to just validate or verify with manual
calculations and we'll use vba for this kind of manual calculations just to verify what the program is
showing me so we don't just blindly trust those uh programs like experiment isis yeah so i hope that
answers your questions so any other questions this time the chat box why leave this here for a while and
see if there are any questions [Music] can we have a question from mr harvest how to practice our logic
for programming um that's sort of difficult to say but um to learn more about programming the only
way to do is start doing it so if you have some assignment let's say whatever you have some assignment
that you want to use your calculate capacity if why not you try use vba and try to solve it maybe that
would be the first so the only way i can tell you is practice makes perfect if you don't start to practice um
you're not going to go anywhere so i was forced to i can say my boss forced me to learn vba to do
programming that's why i can show you an example very easily now but uh of course when a few years
back when i was student i didn't know anything and actually what i had i was forced to learn just to you
can say my boss wants me to learn about in a way i could say that it's something that you have to at
least try out with uh what you have and if you find an opportunity to do it then just do it that's how you
actually improve slowly and slowly you get programming how to type in the logic and so on and
programming is not difficult i will tell you once you get the first or second time you'll be a master already
let's say you can do this you can do one more example then you are an expert it's actually not that
difficult to program especially for generation y people if you ask my mother or my father to do that i
don't think they might say oh it's very difficult to use the computer and so on but i think for us young
people or younger people it should be probably quite easy to pick up as long as we take the effort to go
and try it out with any example that you have yeah so i think that's my answer to your question well
harvey's hope that answers your question okay i have a question from ronald hatta from upn yogyakarta
okay question can we do repetitive looks like wow or four looks in matlab using vba the answer is yes it's
the same actually matlab and vba is the same programming language because they are both object
oriented programming languages as i share in my slide previously and oop language is actually about the
same and just like my testing module so let me open this testing module i show you an example of for
loop so this is actually a four one one example of four so this is a very simple one that just tells you the
uh uh just prints the number one to ten uh i'm sorry just so i'll show you an example that prints a
number one to ten so this is a for loop that actually adds up the sum of the letters so this is example of
for loop so basically anything that you can do in matlab you can do in excel anything that you can do in
matlab you can do it excel simple as that but the way you type in is slightly different the keywords is
slightly different the record and so on are slightly different yeah so i hope that answers your question i
wanna so the simple answer is that you can do anything that you can do in matlab you can do in excel
okay let me go back to the slides for a while just to end up a few slides then we can go to the q a session
for me okay so before i leave today i would just like you guys to have a challenge question just apply
what you have learned return to example two assume that the inlet fuel gas enters at 600 degrees
celsius so in case you have forgotten what is example two let me go back to my excel here example two
so this is the example two well this is example two where i have a full gas i mix with fresh air and then i
get a mixture after the fuel gas infection have mixed together let's assume that this fuel gas is 600
degree celsius and and i'm going to assume that this fresh air is going to employ at 25 degrees celsius
because this is ambient air temperature which is probably something that actually our company does in
the real project for gas turbines we actually do use air to quench this gas turbine exhaust gases and we
have a few projects indonesia actually that does that but i probably will not show you what uh project
because it's confidential so assume that after i mix with french air what's the other temperature so how
do i solve this problem the first scene is to use cp average and set up a goal seek formula for enthalpy so
this is going to be my formula for enthalpy for approximation i am going to use cp always but if you are
free you can calculate with the actual enthalpy formula but actually a double formula involves an
integral so you integrate a plus b t plus ct square and so on so it's more complicated or simple example i
can just show you right here so you just set up a galaxy formula make the total inlet enthalpy equals
outlet enthalpy so energy balance inlet equals our energy balance by changing outer temperature so i'm
going to uh so feel free to connect me on linkedin post the answer and tell me hashtag excel vba i will
tell you if answer is correct i don't want to tell you answer now because uh i want you guys to try out
because the only way to become better at programming is you have to try this so once you have the
answer please post answer and get me hashtag excel with you so this is my profile yeah but i will not
just let you do this like that i'm going to give you some hints on how to proceed don't worry i'm going to
give you some hints so let me go back to excel here so how the rest of this problem is i'm going to put
enthalpy here h um that's the unit i use here so what i'm going to do is i'm going to sell our formula cp
average this temperature minus 25 and for the guess i'm going to show this at this so i will recreate the
cp average using temperature of 625 so i'm going to just assume this is the correct answer in the real life
you might not be using this formula but just for a simple example after i get the cp i multiply by the
kilomole per hour okay and i multiply by the temperature difference p minus 25 so in this case this
temperature is 600 175 so i get a very big number because this unit is very small it's a kilojoule power so
let me just show the unit in kilowatt so i divide by 3 600. let me just put a bracket here and i'm just going
to copy the temperature here just copy and i'm going to just copy this formula all the gases so at 25
degrees celsius and top is 0 because i'm using 25 as a reference state so if you go back to your energy
balance 25 degrees celsius is a reference state you are going to get a copy of zero so i'm going to try the
third one here so what i'm going to do is i'm going to total up the two entropies from outside let me just
use this cell so i'm going to bottle up later in these two and i'm going to do the same thing with the third
one so i'm going to fill in the third enthalpy i'm going to find the formula and i'm going to try some
temperature let's say 625 maybe the answer is 400 this temperature is just to guess that's the initial
guess so it's not accurate it's okay so i'm going to just link the cell to the first one and i'm going to set up
the energy balance here let me just try energy so balance i'm going to allow these two oh it's going to be
so later you can fill in the formulas here then you can see what happens and i'm going to give a balance
and i use the definition in randolph and what i'll do is i'm going to go through data what if analysis
boosting this cell to zero because an energy balance no heat loss no reaction and so on the energy
balance is inlet equal to outlet so inlet equal to another is the same thing as inlet minus outlet equal to
zero right so i'm going to put zero here i'm going to change the outer temperature and one so in this
case this answer is not correct because i didn't fill in the other blanks but i should give you a hint on how
to approach this problem so you can see how ghostly can actually help you with a mass balance so i just
use goal seek i can get the answer for energy balance i need to have some vba or some other formula
but i can also solve the problem using gaussian so this is how you use this is very simple introduction i
just mix two guest streams and i'll show you how excel can be used for mass energy balance calculations
so i hope you like this and if you if you are if you are have some free time you might want to try it out
when you still hot and you can tell me the answer later what's the final temperature so i will tell you
that this is not the correct temperature but because i didn't feel in the other blank so this is not correct
temperature don't be too happy or 98 no 90 is not the correct temperature so temperatures should be
somewhere around 300 to 400 you know the great temperature so please envy only i'm happy to
connect with you if you are any questions do drop me a message on linkedin but just a few key
takeaways before we go into the q a section the first thing is that you can excel in chemical engineering
in excel the name already tells you that you can excel in chemical engineering excel but you need to
know how to use it properly and one of the two tools is to use cosine solver and to solve equations
remember that in ghosting the formula is just a equals to b by changing c a equals to b by chain you see
abc just three things here and if you cannot solve your problems with go seek and solve you go into vba
bpa there are four elements variables operators functions and self-punching and loops just for elements
don't think too much as a starting point just know how to use four elements you can do a lot of things if
you want to be a computer scientist and so on you can go into the details of pda because vpa is a full
programming language there are a lot of things that you can do and but just for engineering application
is enough to know at least these four elements yeah and that's all folks from me today but my final
question takeaway for you is don't wait if you want to improve yourself throughout this korean
pandemic understand that it's a very difficult time and it's not my company is i thinking of you know not
hiring any new people and it's a more it will be a more difficult job market after you graduate as
compared to before the korean pandemic i hope you guys stay safe during this finale i hope you guys tell
okay but if you want to take this opportunity to learn something new to make yourself more marketable
in the job market you can start with learning vba it's very simple and if you know this you impress your
interviewer well you know something that other people don't have and that gives you advantage in the
job market nowadays yeah the job market is really challenging now i'm going to keep you i'm not joking
so i hope that i hope all the best to you and i'm open to your questions so feel free to connect with me
on facebook drop me an email or even on linkedin i'm happy to talk with you if you want to know more
so i think i'll pass back to you um okay sir thank you so much for your explanation that is very clear and i
think we can understand what you mean but i have some question from from participants they direct
message to commit uh committee the first one is from m priority answer chemical engineering
university of lampson first question is how can we get the master of vba and do you have a quick book
of this if you have please share the great book and the second one is the what's the difference between
pba and matlab [Music] okay thank you yanni oh that's a very long question with a very long answer
okay so the first question is uh how do i learn vba how to master vba and what textbooks do you
recommend for vba right that's a question yes the great books the yeah how can we get the master of
vba and do you have the right book of this if you have please share the right book all right thank you for
the question yeah i think that's the question that everyone wants to ask actually i think there's a
hundred people in the webinar i think uh all of you will be interested to know the answer to this
question um the first thing is that i don't use a book i'm a generation why guy i don't read books i i think
books are boring but of course other people have different ways of learning so my way of learning is
actually i go to this website called stack exchange actually my way of learning is let me just go to my
browser here and i'm sharing my screen right so what happens is that if i want to have a problem i'm
going to just search for google i'm very lazy but uh it's very useful so i'm saying google and say how to do
which else in vba excel and there are actually a lot of answers here so actually this is the way that i
learned it's not very systematic and i actually learn based on what the job application requires for
example this is a microsoft official website about how to use default signals so but if you want to have a
more systematic way of learning i actually recommend going on linkedin on linkedin learning there's a
there are many courses to learn excel repair easily so there's one course that i can't find but there is one
course that actually makes it very easy to learn because they give you like one week one assignment five
minutes assignment you just learn something five minutes and then next week you learn something and
something but the problem with linkedin learning is you need to pay money i think it's like 20 us dollars
per month so it's quite expensive probably for me for you i'm not sure but uh it's one way that i would
recommend to them on linkedin and it's very guided and you can ask them questions and events they
will answer to you if you want a book if you want a book for textbook for learning excel and vba i
recommend the book excel for chemical engineers i recommend this book i'm not sure if you can get it
by amazon or something but let me just i think this is a book that i meant so this is one of the better
ones uh and it's not that expensive so i'm not sure how you can get the ebook webs you can buy it on
amazon or something like that but this is one of the better books that i can try and the good thing is that
it gives you a comparison between excel vba and matlab so you can do the same thing in matlab you can
do the same thing vb and then you can compare the answer whether it's the same if it's the same then
congratulations if it's not the same then something's wrong and focus you should go back to your code
and check out so this is one of the one of the simpler books i recommend for this uh how to learn vba
and excel easily in uh for students perhaps or even for working people it's actually a good way to learn
also yeah so i think you need to answer hope that answers a question from from this person okay so it's
me if we see the windows from the cba and the method is uh similar right so what is difference between
pda and okay what is different between vp and mlm good question i think matlab is something that you
learned in a chemical engineering course where in most united states even in university of malaya when
i was a student we learned matlab for calculations so the main the main difference i would say is that
matlab is designed for engineering applications vba is not designed for engineering applications so that's
the main difference so for example in matlab you have a matrix manipulation in vba you can do matrix
manipulation but it's a bit more difficult because uh excel is after all a program that is supposed to be as
i said in the earlier myth is supposed to be something used by accountants statisticians mathematicians
and so on and it's not really designed by and for an engineering application in the first place so that's
why you don't have certain matrix manipulation calculations for example you want to um calculate the
determinant of a matrix and so on it's not that easy excel does have certain matrix manipulation
functions and vba also has that but it's not straightforward compared to matlab so that is the main
difference that i see the second is when you are solving pde because in in matlab if you have a the what
you call the toolkit you can solve a partial differential equation you just type in one formula enter you
can get a partial differential equation solution excel you don't have that because excel is not designed
for the account application but for all other applications i can say almost any application matlab is the
same as vba same functions uh same applications just the way you type in is different maybe you have a
bracket here in magnet you don't have a record maybe in matlab you can type in a you need a
semicolon in vba you don't have a semicolon so it's actually similar but the good thing about vba is that
vpa is found inside excel right and a lot of people in this role excel whereas matlab is more specialized
software not everyone has matlab um my friends studying in let's say economics will not have matlab
only engineering students mostly or engineers when i met them so excel is something that almost
everyone in the world has right so you can code something vba and share with other people for example
i can do thermodynamic cooperation i can share the to someone else and he can do it continue for my
calculations which is something that matlab doesn't do that well because that guy will need to have
matlab as well if you want to share matlab uh code to the other person so that's what i would say the
main difference between like vba and matlab is that man lab is an engineering application but on the
other hand excel is something that more people have and it's more common so that it's easier to share
between other people and you don't have to have a license or matlab for example but in unity or malaya
matlab is only available inside the computer in the computer lab so if i need to use my lab i have to go to
uh unicity i have to go there and it might not be a convenient for me maybe it's like saturday or sunday
or always after hours but excel is something that i can use any day anytime i want yeah so helpful to
answer the question okay so for the matlab and cba and excel is different application right yes but they
have the same function i would say okay so if we if we want to get the vba application how we can get it
just typing in the google or you have the link uh vba is something inside excel so if you want to open
media you just open excel everyone has it everyone if you excel you have the application you just have
to uh let me just show you again click on developer yeah so there's so everyone here i can say every 100
you have this vba application you just never open it before right right that's all that's fine but that's a
good question many people don't realize that it's actually very useful too okay thanks any okay the third
question from ronald berlin newman from university of maiden area the question is how to utilize excel
in chemical engineering how to that's a good question i think you have to rewatch my web binder again
but the simple things is that you can use vba to calculate heat capacity enthalpy density viscosity
diffusion coefficient mass transfer coefficient heat transfer coefficient convection radiation basically
anything in chemical engineering if it's a formula you can write in vba that's my simple answer to that
question because after all vp is just a programming language it helps you to calculate something and
there's something as long as in the form of a formula you can calculate that's a simple answer to that
question yeah that that would be answer hope that answer the questions on jenny okay this is some
question also from the chat is from juliandre yeah uh when we click the insert on cba project then sell us
three different styles such as user from module and class module my question is what are the difference
and why you just use module thank you thank you julian that's uh i think you have some background in
programming like as a compression yeah that's a more difficult question um for most of you will be very
confusing but i'm just going to go back to my vba screen here and i'm just going to show what uh julian
doing is showing so i can right click insert and there are 3d types here right so we have user phone
module and glass module so uh and julian is asking what what's the difference between these three and
why i just use module okay so um so the difference is that module is something that i can put some code
inside and i can share this code with other people for example i can click on example 5 right click export
file and i can save it somewhere and i can send this file to another person he can open the module and
he'll have the code immediately inside his excel so now i have the quote he has the code so this is a
good way of sharing vba code and the module allows you to access the code from any sheet for example
we have sheet one two three four five here but when if i'm using the sheet to type in the code the code
will only be available inside the sheet so i try to let's say one in sheet two it will say formula but if i i run
the code in the module all the chain can access this module so all the all the kids can access the same
code so that makes it very convenient and very easy so what are the two other types here a useful form
and cost module okay usable is something that allows the user to plug in something so i can create a
window and i can ask you to fill in temperature pressure okay then something comes up so there is a
user form it's a more difficult one for simple applications i don't use user phone but my company some
people do use google form so they can actually create their own app inside excel so inside yourself you
can see a window and type in temperature pressure okay then density comes out for example so that is
how you can actually create your own program inside excel so you can be a real programmer if you want
because module allows you to define classes so a class is a very object-oriented programming kind of
concept it's a multiple concept but if you want to know more it's a way that allows you to define classes
subclasses and you can access these classes inside the module so class module is actually similar to a
module except that there are certain other functions related to object oriented programming which is
something that will take a very long time to cover probably one whole day so i'm not going to talk too
much about it today so i hope that answers your question julian okay there is the third one the third one
the question oh no still have two questions uh the first uh the from ronald palin uh from dinasparindak
profits the question is what is percentage of the affiliate content in the air maybe the his maybe i think
this means example number two maybe about the oxygen content uh in process printing i'm not sure
but maybe in the example number two okay um i can give you the example answer and the real answer
the real answer is that the oxygen content in air will differ depending on where you are the air
emulation might be from the mixture and united states my different but the range is around 20.5 to
twenty point four percent so in this example i just use a simple twenty one more pretend to make it
easy for you to calculate but in real life the oxygen content will differ and air will actually contain more
gases you have water co2 you have argon you have rare gases to have uh like like proteins well this is
just a simple example to make it easy for you to calculate don't treat this as a real project in my real
project for a guest to buy we calculate more accurately of course this is just an example for to cut you
on the basics of epa so just to answer you the question is that i put 21 more percent and 79 more
percent at night which that's how i choose the composition i hope that answers the question on rolling
okay the last one this uh from richard abbey with the question is can we do this all comments in less
version official basic example cb 20 2019 if not what the person thought we used to do this comment uh
thank you for the question uh richard that's a good question also uh i would like to just clarify that vba is
visual basic for application and virtual basic is another different programming language here so don't get
confused visual basic for application aba is different from visual basic i don't know why they put these
names you have to ask microsoft for the inventors similar names but the visual basic is used for windows
application for example uh internet explorer i will use visual basic to write the whole internet explorer
program inside visual basic and you are correct to say that visual basic has received different versions
some versions are newer older and if you want to know more about visual basic you have to go to
microsoft's website their update was the latest version but just to clarify we are now discussing visual
basic for application vba and vba the version of vba you use depends on the excel or office version that
you have so for example i'm showing excel 20 2016 the vba will be based on 2016. so the version based
on the uh the microsoft office version that you installed and there are some changes but i can say that
vba is a language that has very few changes throughout the version if you compare with um python or c
plus plus or other programming languages or java every version has a very big change so if you write i
write some code in python version one i go to python version two maybe you cannot run but for vba i
can say with very high confidence that the changes are very very small and all the examples that i
showed today the vpa will book in any application it will actually probably work even if you go back to
excel 1997 1995 it will still work so i can assure you on that yeah so don't worry too much about the
versions for vba the version changes is very very small and usually not important i hope that answers
your question richard okay i think that's also for the question and you are so well to explanation uh and
you answer very well and very clear i think and thank you so much for your uh your time in this webinar
and i think the conclusion we can get the we can uh we can use the application pda in our computer
using uh and we already have in the excel application and when we do when we can use the pba is for
the representative text complicated text and interactive text and and then for the visual basic for
application or pba is they referred from visual basic intricate into microsoft office application allow for
user defined function and object-oriented programming language and i think if we want if we use this
dba and extra simulation is make us easier if we have a lot of data or a lot of some sample we need to
calculate it makes us easier and can minimize our time and um more efficient i think right okay i wanted
to invite you guys to connect with me on linkedin and facebook and drop me an email if you want to
know more yeah thank you very much yani for the nicest conclusion [Music] [Applause] uh wait bit sir
you think something will ah okay maybe i just uh closing this webinar i'm not sure what's wrong with
them so thank you all for all participants in this webinar i'm so happy you are have time to listening in
this webinar and thank you so much for mr dia uh yeah yeah right we are so uh we are so happy you can
you can give some material in this webinar and thank you so and we much we can see you next time
nice to meet you thank you thank you to all the participants for spending your saturday morning which
probably many people will be on holiday or or doing whatever you want to do but you are actually in
this class listening to it yeah so congratulations thank you very much for joining thank you sir please
commit anitia thank you very much mr rahul and mrs msc finally we come to the end of this event to
close this event that's reciting hamdallah alhamdulillah well ladies and gentlemen thank you very much
for your participate and your nice attention if in guiding this event i make mistakes or often someone
here please forgive me okay thank you wassalamualaikum warahmatullahi wabarakatuh um um my oh
so so [Music] um uh uh please to all audience turn on your camera because we want to documentation
and also mr thank you yeah let's see okay picture okay thank you for your attention maybe enough and
see you to the next webinar okay um hmm

You might also like