Class Note for CHEE 201L with Professor Blowers at UA
Class Note for CHEE 201L with Professor Blowers at UA
Popular in Course
Popular in Department
This 5 page Class Notes was uploaded by an elite notetaker on Friday February 6, 2015. The Class Notes belongs to a course at University of Arizona taught by a professor in Fall. Since its upload, it has received 15 views.
Reviews for Class Note for CHEE 201L with Professor Blowers at UA
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 02/06/15
an 2m Camp Inquot Reading Number Mast students are already very famdnr w h Excel and many uf une mas um are mm mm m sa wue package has a mid packag fax malynng data malang pins and axgmzmgmfammhan Hawwex there as a budLm campulex language called szual E asxc v EA that gves assess in much mare pawexfu data pmcesangtanls Ths semmwxll anuamee studmtsta VEA as 1th usedexcel sa they eanbegnm use campulex pragmmmgm salve pmblems Lemng Ob ecuves 1 Studentswx lumhawmlabel eeusanExeex 2 Studmtswx 1eamnaw m sendmfammummm szual Easxc mm Exeex z Studmtswx 1eamnaw m sendmfammumback ram Vasua1 Ease in Excel Eeran we began aeus nean mam uses a gen a nan a nananrannaaan Exanane an ngne beaaw a ananeaarwnaensneans A x a x z x a x E x G Weseemaswenavesaneeen Mane amen spnaasneea uyms wtwhmhe shaman eannnnen an an anne sneea Webasenaynavewneaanannen annrannaaanm heap as wna an sheen abanennennsx an be me neagns aren mane nrees m m 5W2 Amy M W Lsnee me nsnnse an mane has ana enea snss nasannrees mg a W m m and mm m thbbz a sansnns enema o a nasune wane ran mamaname Lsnnne me nss aeassens sane sa 1 o Lakewase km 11 has me 1abe1 b n E eaannnn anams vane an eaannn m a Wemennaveaeamearaasa begnnngn km 14 and eanannng amenaenasx vanes any vanes enenaeeawaununse Equaunnmbzuszd 1 m cammts Thus 15 standardExcel nnaeuee andsmdzntsshauldbe W mquot famdnrwnhhaw m sennesun and 00 220 hwwta setupthz equahansta sun 5m makethetable 4 em 535 gm Fax exanpae men39s wau dhwe MD 6530 P e m 3310 muzme m m mce EIA Thenuneyennnnse m m gauge Dawnta eanyune fuzmu a W mm mtathe ce sbelaw m Remember unanne aaun sagns 1n me rannuxa pmtect that sen and me new famm as beneaun me mgnal ane WI sun refer ta unase eeus Try typmg an une rannuxa and dmng n dawn wnhaut une da ar sgas in see naw une nmgxan enanges referenced eeus aryau aren tfamdnr waununsmek We wan learn arew mas befme we begnta senn une Excel VEA Instead uf da ar sgns we cvmdhave created aName fax eeus Em anaEn Thsxs dune by uhchng an Lnsen amegxenteLe CalumnOn waun eeus AID anaEm negmgmen an chckmg an een mm M annw yaum see unanne Value xslabelled students could now replace 2mm ln thelr equatlon wlth the letter m and Excel would correctly compute the equatlons You can als labelb and lts value the sameway Now that we see how to set up labels we wlll tum to how to access VBA ln ordato 581d lnformatlon lnto and out othe progammlng language You can thnk of Excel and VBA as acqualntances that don t really do a lot togethe The analogy ls illez y be the height afan urplane m t that they are fnends that may send each othe ennallback and i Luxbe rhe distance the ailpiane has forth butthey cetamly wouldn t go outto dmnetogether You ll n gunmmnmmqunmm see what we mean by thls n a few more mlnutes T Le m be m an of ce Equal w 1 9 Lumple nfExcel Spreadsheel 7 3 Izquauonm beused t metro L The flrst thmg you should do to enable VBA to run on the compute you are worklng on ls to set the securle settmgs Thls 1 3 15 can be done by golng to Tools QpLIOnS gecunty Macro gecurlty or Tools Macro gecunty dependlng on whlch yeslon ofExcel you are uslng and setttng thls menu to Low Baslcally ths wlll enable Macros to run and VBA on the compute you are workmg on Thls secunty change may enable some Macros to run that are Vlruses so you should not acceptExcel flles from people you don t lmow when your secunty settmg ls set to Low llke thls The menu you 3 shouldhavejustfllledoutwllllookllke genmtyteyel Irusfsd Sources I when you cllck OK you will now be able to run VBA on your compute If you eye slt down to a new computer and wonder why the VBA program you had been runnmg on othe computers ls now notworleng you should reset tlne secunty level to Low on the new computer followmg tlne steps we Just did r Lllgh only slgned mauasttam trusted saurtes le he a uwed ta run unsnned macros are aummaocallydlsahled r Medlum Van an manse whemev Dr natla run patenaally unsate means r Law natremmmerlded ynu are natamteeed an annoally unsafe mamas Use ttus semng anly lf tuu have ylyussmnnlng sn ware lnslalledy nryau ave sureall documents you open are safe Ifwe want to get to VBA m Excel we cllck on Tools Mam ylsual Bale Edltor and we get a screen that looks llke thls In the uppe left comer Hpcmsoft sunl Basic r OtEEZ ltomputerr Elle gdlt mew lnsert Fgrmat erug E Na vlms starlrler wstalled me Now cllck onTnsetModule Thls opens up anew Ewan EdCIIEEIU o Wmdow whee you wlll type ln your compute code so that Excel lmows where to nd rt At thls polnt we need to make a few comments about VBA and how rt comp ares to othe progammlng languages VBA ls geat forsetttng up gaphlcal use lntefaces GUTs wheepeople cllck on menus and enter lnformatlon lnto boxes Ifyou ve taken a JAVA class you may already be famlllar wlth these tools and how to use then Howeye VBA also can be used much as one uses c c FORTRAN BASIC or any of the othe computer languages you may already be famlllar Wth W39hlle students are often wary of leammg computer E S ldmso eel omem 53 Sheen Fl 2 ll n3 Sheelz Flgule z a sham Shem 53 Sheet shears ThSn39lnrkbnm progammlng they soon reallze that once they have learned how to program m one language then othe languages are easy to pick up and use The differences between computer programming languages and how you get them to operate is in the syntax you use in order to get the program to understand what you want it to do A good source of information about any language is the internet If you ever find yourself stuck and you aren39t sure how to create a short section of code to do something try using a search engine and typing in for example Visual Basic AND Tutorial You39ll be surprised at how much free information is out there on how to program Let39s now see how to send information into and out of VBA Type the following lines into your open VBA module window that came up when you did lnsert Module Option Explicit Function Sendm Send m End Function Notice that the program automatically added a line under Option Explicit and it also automatically added End Function once you typed in Function The Option Explicit tells the VBA program that you will be defining and dimensioning the variables much like you would in FORTRAN This allows you to keep track of your variables and makes sure you aren39t making any mistakes If this doesn39t seem to make sense to you yet basically we will need to tell VBA at the beginning of our program what our variables are and what type they are integers decimals strings of characters etc We39ll come back to this topic in a little while so don39t worry if it seems confusing right now Now that you have set up this very short program go back to your Excel sheet and enter HSendBl4 into cell C14 Now copy this formula C14 cell into the cells beneath C14 What do you notice We see that we are just getting back the number that is in the column to the left of column C Let39s look at our program now and figure out what it was doing If you remember we said that VBA and Excel are acquaintances but not really good friends When you typed HSendB14 into Excel you were telling Excel to package up the information from cell B14 and send it to its acquaintance VBA VBA will just sit there patiently waiting until it receives this information before it will start to run the program Once it receives the information in Send it runs through the program When VBA encounters quot Send m at the end of the program it takes m packages it up and send it back to its acquaintance Excel to put in the cell where you put in your formula One thing you should notice is that you have used predefined functions in Excel all the time in the past You are probably used to entering something like HexpA14 into a cell to take the exponential value of the number in cell A14 Well with VBA we have just created our own function called Send This brings up one point that you must be careful about when creating a VBA programming function You aren39t allowed to create a function that has a name that is the same as one already predefined in VBA or Excel If you used Exp instead of Send the program might either give you the exponential of the value or it might give you an error Since there are thousands of functions predefined in Excel you may need to try a few names for your functions before you find one that works Let39s try a few things here to have you become a little more comfortable with how VBA and Excel are working Let39s add a few lines to our VBA module until it looks like this Option Explicit Function Sendm Dim n as single nm 2 Send n End Function Whehwe make these ehehgeste eurpregrem we see thetwe ere sun smdmgmmfmmaumfmm the hen te the eert quhe me we ere typrhg Send rhte Heweyer the VEA pregrem rew adds ehew yereehee r te the ehes rt emuse m ardex te da calculahans We ameheeheathes mum wrththe hhe Dem re es ange teurhg rtwe heye ehew yereehee r ehethetwe wen he eemg engepreereeh wen eeme heehtethesrssee ufhww ehmeheemhg remhers eeh affectqu enswers m e hter reeehhg per new there ere twe gaad eheeeesrer the mmherswe WI he heheumg whnch ere the me wejmtmed ehe Dem re es dwuble The ehrrerehee heoween the ewe rsthet dauble eerreestwree es mehy spaces te haldnumbers es ehge dues se Lhatwumay getmere eeeurete ehswers The mnddlelmz quhepmgam r 2 tehestheye1ue m muttephesrthyz ehethehsehes manufamaum back te re rershew equal te the value m thet eeme mte the pregrem hen A14 fer the tep hhe umesZ Serra retheretehesthe Value err mdpukagesxtw saExcel eehputthe ehswerrhthe een teeming emrs 2nd where they heme um A gaadpncuce whenever we ere 1eerrehg hew te use e eemputer pregrem rste see whet errersyeu get where yeu knewrhgy da sem ethehg wrehg Try the fa awmg and wrrte dwwn whet heppehs whzn we 60 rt Frrst rem eye Dem re es ehgh here the lastpzagam yeu werejustwakag er and ge back mte Excel end deck er eeu A A and het ereer Ywu ll seematwu getanermzhke menereu the ehetethe reght VEArs ereerey mee pregremmmg 1enguege te eee m seme respects heeeuse rt enehteus yeu when wu ve made en errer Here rt gyes es the wrheew tenrhg uswhntxt mnksxswmng Thehrt heghhghts m the pregrem where rt eheeehterea the errer A Camw e errar teneete net eetnee VEA eese wermetus canunue unnl we admawledg the errer metryte x rt oh the VEA menu wu u hew heye te chuk ehoK and eeethe ehmeheemhgeme back m ohee we heye eehe thet yau ll heeate chck ehgmgesetrh eraerte enew Excel eheVEA te Lalk te ehe ehether egeeh Ifwulaakedback etthe Ereee sheet m the mreene uf testehg thes errer yeu wauld heye seer sem ethehg hke w ALUE er NMEv m seme af the hens wen heme back te thes phenamem m e htue hrt me these ere ether mdlcaums thetyeer pregrem xm t dmng whet rt s suppesee te he damg wen er VEA xm t gyehg yeu en errer ohe ex Ample rs er yeu haven t resetyeur seeurety settehgs te law ThehEreee wan tbe ehee te getrhrermeteeh te VEA eheyeem prehehey get the NMw reshtt m ymx eeu where we entered Wm famm a xhthes eese where we ve Just putthe ameheehstetemehtheek ere we see thet the eerreet ehswershew eeme back mte eer hens ehee we ve dune RunResennLhe VEAmadu e Lets try erew ether weys afgemng errershew thetyeu see whet heppehs 1 chehge Sendnm Seheamhhewh and see whetheppehs 2 wrth s ehemhhewh there ehehge the am stetemeht te arm re es ange unlmawn es ange and chuk er gmgeset Ge back te Excel and see whetyeu get es e um z Stert aver wrth yeer wakag pregrem ehe ehehge chan Seheem te Funcum 5 may Whet dues Excel gye yeu ehe whet errer da yeu getv Lets laak et e shgrtey emerehtpregrem te da seme ether calcuhnans ceese euterEreee eheVEA te hegen aver wrth ehew example thettehes owe memhersrhte VEA and campules yfmm them Justhke Excel ehehr mx eregmee gue Type the renewrhgrhte ymx rew VEA maduh Option Explicit Function linem x 1 Dim yAs Single y m x 1 line y End Function Now set up a table like was shown in the first figure of this section Label the m and b cells Now go to cell A 14 and enter HlinemAl4bquot With our two labels for m and b we get the same answers in the first figure If we copy the cell down into the places beneath it we see that the A14 reference changes and we get all the answers we expect We now have seen how to send more than one variable into VBA and how to use the numbers to calculate other values This will be useful later on as we move to more complicated programs You are now ready to do Computer Homework 1
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'