What is a VBA Macro in Excel? - Corporate Finance Institute
文章推薦指數: 80 %
VBA Macros use the Visual Basic Application in Excel to create custom user-generated functions and speed up manual tasks by creating ... Home›Resources›ExcelResources›Study›VBAMacros VBAMacros HowtosetupmacrosinVBA Writtenby CFITeam UpdatedFebruary9,2022 WhatareVBAMacrosinExcel? VBAMacrosusetheVisualBasicApplicationinExceltocreatecustomuser-generatedfunctionsandspeedupmanualtasksbycreatingautomatedprocesses. Additionally,VBAcanbeusedtoaccesstheWindowsApplicationProgrammingInterface(API). Oneofitsmainusesistochangeandcustomizetheuserinterfacebycreatingpersonalizedtoolbars,menus,dialogboxes,andforms. Tolearnmore,launchCFI’sExcelVBAcoursenow! Beforeyoucontinue,usetheformbelowtogetaccesstoourcomprehensiveVBAcheatsheetforanoverviewofkeycodesandmacros,terminology,andbestpracticesinExcelVBA. HowtoCreateExcelVBAMacros Inaseparatearticle,CFIdiscusseswhatVBAisandhowtoaccesstheVBAEditor.Asasummary,pressingAlt+F11inExcelopensuptheVBAwindowandallowstheusertobegincodingmacros. Tostartcoding,theuserwillhavetocreateaModulefile.Modulefilescontainagroupofmacros.Tocreateanewmodule,pressInsert>Module.Optionally,theusercannamethismoduleusingthepropertieswindowinthebottomleftcorneroftheeditor.Simplytypeinanewmodulenameandpressenter. HowtoNameExcelVBAMacros Tostartoff,themacromustbegivenauniquename.Thisnamecannotmatchothermacros,anditusuallycannotmatchthenameofotherproperties,functions,andtoolswithinExcel.Themacronameiswhattheuserwillusetocallthemacrointoaction. Todefineamacroname,theusermusttypeSubname()andpress“enter”inthecodingwindowoftheeditor.PressingenterwillautomaticallyfillthewindowwiththegeneralformatofanExcelmacro.Forexample,tonamethemacro“CFIMacro”,ausershouldtype“SubcfiMacro()”andpressenter.TheVBAEditorwillautomaticallyaddan“EndSub”lineafewlinesbelowthe“Sub”. Note:Thegeneralconventionfortypingnamesforanymacro,function,orvariableinVBAistouselowercaseifthereisonlyoneword,andtouseanuppercaseletteratthestartofeverynewword.VBAnamesgenerallycannotcontainspaces.SinceCFIMacroistwowords,thisshouldbewrittenascfiMacro.However,thesearejustbestpracticeguidelinesandneednotnecessarilybeadheredto. SubNameinVBA TheSubName()linetellstheeditorthestartofthemacrocode.TheEndSubdenotestheend.Iftheuserwantedto,heorshecouldcreateasecondnewmacrobystartinganewSubName()linebelowthefirstEndSub.TrythisoutandyoushouldnoticethatExcelwillautomaticallycreatealinebetweenthetwodifferentmacros. ThisisthebasicstructureofanExcelmacro.Thenextstep,beforejumpingintotheactualprocesscoding,istodefinethevariablestheuserisgoingtouseinthecode.Youmaybeinterestedinourfully-fledgedExcelVBAmacrocourse.Clickhere tolaunchthecoursenow! AdditionalResources ThankyouforreadingtheCFIintroductoryguidetoVBAmacrosinExcel.Tokeeplearningandadvancingyourcareer,checkouttheseadditionalCFIresources: ExcelShortcuts(PCandMac) AdvancedExcelFormulas ListofExcelFunctions FreeExcelCourse Sharethisarticle GetCertifiedfor BusinessIntelligence(BIDA™) DevelopanalyticalsuperpowersbylearninghowtouseprogramminganddataanalyticstoolssuchasVBA,Python,Tableau,PowerBI,PowerQuery,andmore. LearnMore CorporateFinanceInstitute BacktoWebsite 0searchresultsfor‘’ Peoplealsosearchfor: excel Free freecourses accounting Balancesheet 2 DCF ExploreOurCertifications FinancialModeling&ValuationAnalyst(FMVA)® Learnmore CommercialBanking&CreditAnalyst(CBCA)™ Learnmore CapitalMarkets&SecuritiesAnalyst(CMSA)® Learnmore CertifiedBusinessIntelligence&DataAnalyst(BIDA)™ Learnmore Resources ExcelShortcutsPCMac ListofExcelShortcuts Excelshortcuts[citation... FreeFinancialModelingGuide ACompleteGuidetoFinancialModeling Thisresourceisdesignedtobethebestfreeguidetofinancialmodeling!Wewillbreakdownthemostimportant... SQLDataTypes WhatareSQLDataTypes? TheStructuredQueryLanguage(SQL)comprisesseveraldifferentdatatypesthatallowittostoredifferenttypesofinformation... StructuredQueryLanguage(SQL) WhatisStructuredQueryLanguage(SQL)? StructuredQueryLanguage(SQL)isaspecializedprogramminglanguagedesignedforinteractingwithadatabase.... SeeAllResources SeeAll PopularCourses Free! FMVA®-PrepCourses 3.5h ExcelFundamentals-FormulasforFinance FMVA®-Required 5.5h Buildinga3StatementFinancialModel FMVA®-Required 7.5h BusinessValuationModelingPartI FMVA®-Required 2.5h Scenario&SensitivityAnalysisinExcel FMVA®-Required 6h Dashboards&DataVisualization FMVA®-Electives 11h LeveragedBuyoutLBOModeling SeeAllCourses SeeAll RecentSearches Suggestions FreeCourses ExcelCourses FinancialModeling&ValuationAnalyst(FMVA)®
延伸文章資訊
- 1EXCEL VBA從頭來過-基本語法(上篇) - 張凱喬
VBA(全名為Visual Basic for Applications) 是一種Windows 下的巨集程式語言其語法承襲傳統的Visual Basic 在微軟Office 之中的各種 ...
- 2Top 100 Useful Excel Macro [VBA] Codes Examples
In Excel, macro code is a programming code which is written in VBA (Visual Basic for Applications...
- 3How to Create a Macro in Excel (In Easy Steps)
With Excel VBA you can automate tasks in Excel by writing so called macros. In this chapter, lear...
- 4What is a VBA Macro in Excel? - Corporate Finance Institute
VBA Macros use the Visual Basic Application in Excel to create custom user-generated functions an...
- 5Excel Vba Macro Programming - 博客來
書名:Excel Vba Macro Programming,語言:英文,ISBN:0072231440,頁數:319,作者:Shepherd, Richard,出版日期:2004/02/04,...