Excel宏英文.docx
- 文档编号:28965495
- 上传时间:2023-07-20
- 格式:DOCX
- 页数:7
- 大小:25.56KB
Excel宏英文.docx
《Excel宏英文.docx》由会员分享,可在线阅读,更多相关《Excel宏英文.docx(7页珍藏版)》请在冰豆网上搜索。
Excel宏英文
Createordeleteamacro
Appliesto:
MicrosoftOfficeExcel2007
Toautomatearepetitivetask,youcanquicklyrecordamacro(macro:
Anactionorasetofactionsthatyoucanusetoautomatetasks.MacrosarerecordedintheVisualBasicforApplicationsprogramminglanguage.)inMicrosoftOfficeExcel.YoucanalsocreateamacrobyusingtheVisualBasicEditor(VisualBasicEditor:
AnenvironmentinwhichyouwritenewandeditexistingVisualBasicforApplicationscodeandprocedures.TheVisualBasicEditorcontainsacompletedebuggingtoolsetforfindingsyntax,run-time,andlogicproblemsinyourcode.)inMicrosoftVisualBasictowriteyourownmacroscript,ortocopyallorpartofamacrotoanewmacro.Afteryoucreateamacro,youcanassignittoanobject(suchasatoolbarbutton,graphic,orcontrol)sothatyoucanrunitbyclickingtheobject.Ifyounolongeruseamacro,youcandeleteit.
Whatdoyouwanttodo?
Recordamacro
CreateamacrobyusingMicrosoftVisualBasic
Copypartofamacrotocreateanothermacro
Assignamacrotoanobject,graphic,orcontrol
Deleteamacro
Recordamacro
Whenyourecordamacro,themacrorecorderrecordsallthestepsrequiredtocompletetheactionsthatyouwantyourmacrotoperform.NavigationontheRibbonisnotincludedintherecordedsteps.
Note TheRibbonisacomponentoftheMicrosoftOfficeFluentuserinterface.
1.IftheDevelopertabisnotavailable,dothefollowingtodisplayit:
1.ClicktheMicrosoftOfficeButton
andthenclickExcelOptions.
2.InthePopularcategory,underTopoptionsforworkingwithExcel,selecttheShowDevelopertabintheRibboncheckbox,andthenclickOK.
2.Tosetthesecurityleveltemporarilytoenableallmacros,dothefollowing:
1.OntheDevelopertab,intheCodegroup,clickMacroSecurity.
2.UnderMacroSettings,clickEnableallmacros(notrecommended,potentiallydangerouscodecanrun),andthenclickOK.
Note Tohelppreventpotentiallydangerouscodefromrunning,werecommendthatyoureturntoanyoneofthesettingsthatdisableallmacrosafteryoufinishworkingwithmacros.Formoreinformationabouthowtochangethesettings,see
ChangemacrosecuritysettingsinExcel.
3.OntheDevelopertab,intheCodegroup,clickRecordMacro.
4.IntheMacronamebox,enteranameforthemacro.
Note Thefirstcharacterofthemacronamemustbealetter.Subsequentcharacterscanbeletters,numbers,orunderscorecharacters.Spacescannotbeusedinamacroname;anunderscorecharacterworkswellasawordseparator.Ifyouuseamacronamethatisalsoacellreference,youmaygetanerrormessagethatthemacronameisnotvalid.
5.ToassignaCTRLcombinationshortcutkey(shortcutkey:
Afunctionkeyorkeycombination,suchasF5orCTRL+A,thatyouusetocarryoutamenucommand.Incontrast,anaccesskeyisakeycombination,suchasALT+F,thatmovesthefocustoamenu,command,orcontrol.)torunthemacro,intheShortcutkeybox,typeanylowercaseletteroruppercaseletterthatyouwanttouse.
Note TheshortcutkeywilloverrideanyequivalentdefaultExcelshortcutkeywhiletheworkbookthatcontainsthemacroisopen.ForalistofCTRLcombinationshortcutkeysthatarealreadyassignedinExcel,seeExcelshortcutandfunctionkeys.
6.IntheStoremacroinlist,selecttheworkbookwhereyouwanttostorethemacro.
Tip IfyouwantamacrotobeavailablewheneveryouuseExcel,selectPersonalMacroWorkbook.WhenyouselectPersonalMacroWorkbook,Excelcreatesahiddenpersonalmacroworkbook(Personal.xlsb)ifitdoesnotalreadyexist,andsavesthemacrointhisworkbook.InWindowsVista,thisworkbookissavedintheC:
\Users\username\AppData\Local\Microsoft\Excel\XLStartfolder.InMicrosoftWindowsXP,thisworkbookissavedintheC:
\DocumentsandSettings\username\ApplicationData\Microsoft\Excel\XLStartfolder.WorkbooksintheXLStartfolderareopenedautomaticallywheneverExcelstarts.Ifyouwantamacrointhepersonalmacroworkbooktoberunautomaticallyinanotherworkbook,youmustalsosavethatworkbookintheXLStartfoldersothatbothworkbooksareopenedwhenExcelstarts.
7.IntheDescriptionbox,typeadescriptionofthemacro.
8.ClickOKtostartrecording.
9.Performtheactionsthatyouwanttorecord.
10.OntheDevelopertab,intheCodegroup,clickStopRecording
.
Tip YoucanalsoclickStopRecording
ontheleftsideofthestatusbar.
TopofPage
CreateamacrobyusingMicrosoftVisualBasic
1.IftheDevelopertabisnotavailable,dothefollowingtodisplayit:
1.ClicktheMicrosoftOfficeButton
andthenclickExcelOptions.
2.InthePopularcategory,underTopoptionsforworkingwithExcel,selecttheShowDevelopertabintheRibboncheckbox,andthenclickOK.
2.Tosetthesecurityleveltemporarilytoenableallmacros,dothefollowing:
1.OntheDevelopertab,intheCodegroup,clickMacroSecurity.
2.UnderMacroSettings,clickEnableallmacros(notrecommended,potentiallydangerouscodecanrun),andthenclickOK.
Note Tohelppreventpotentiallydangerouscodefromrunning,werecommendthatyoureturntoanyoneofthesettingsthatdisableallmacrosafteryoufinishworkingwithmacros.
3.OntheDevelopertab,intheCodegroup,clickVisualBasic.
4.Ifneeded,intheVisualBasicEditor,ontheInsertmenu,clickModule.
Note Modulesareautomaticallycreatedforallsheetsintheworkbook.
5.Inthecodewindowofthemodule,typeorcopythemacrocodethatyouwanttouse.
6.Torunthemacrofromthemodulewindow,pressF5.
7.IntheVisualBasicEditor,ontheFilemenu,clickCloseandReturntoMicrosoftExcelwhenyoufinishwritingthemacro.
TopofPage
Copypartofamacrotocreateanothermacro
1.IftheDevelopertabisnotavailable,dothefollowingtodisplayit:
1.ClicktheMicrosoftOfficeButton
andthenclickExcelOptions.
2.InthePopularcategory,underTopoptionsforworkingwithExcel,selecttheShowDevelopertabintheRibboncheckbox,andthenclickOK.
2.Tosetthesecurityleveltemporarilytoenableallmacros,dothefollowing:
1.OntheDevelopertab,intheCodegroup,clickMacroSecurity.
2.UnderMacroSettings,clickEnableallmacros(notrecommended,potentiallydangerouscodecanrun),andthenclickOK.
Note Tohelppreventpotentiallydangerouscodefromrunning,werecommendthatyoureturntoanyoneofthesettingsthatdisableallmacrosafteryoufinishworkingwithmacros.
3.Opentheworkbookthatcontainsthemacrothatyouwanttocopy.
4.OntheDevelopertab,intheCodegroup,clickMacros.
5.IntheMacronamebox,clickthenameofthemacrothatyouwanttocopy.
6.ClickEdit.
7.InthecodewindowoftheVisualBasicEditor,selectthelinesofthemacrothatyouwanttocopy.
Tip Tocopythewholemacro,includetheSubandEndSublinesintheselection.
8.OntheEditmenu,clickCopy.
Tip Youcanalsoright-clickandthenclickCopy,oryoucanpressCTRL+C.
9.IntheProcedureboxofthecodewindow,clickthemodulewhereyouwanttoplacethecode.
10.OntheEditmenu,clickPaste.
Tip Youcanalsoright-clickandthenclickPaste,oryoucanpressCTRL+V.
Tip YoucannotedityourPersonalMacroWorkbookfile(Personal.xlsb)becauseitisahiddenworkbookthatisalwaysopen.YoumustfirstunhideitbyusingtheUnhidecommand.YoucanalsoopenitintheVisualBasicEditorbypressingALT+F11.
TopofPage
Assignamacrotoanobject,graphic,orcontrol
1.Onaworksheet,right-clicktheobject,graphic,orcontroltowhichyouwanttoassignanexistingmacro,andthenclickAssignMacro.
2.IntheMacronamebox,clickthemacrothatyouwanttoassign.
TopofPage
Deleteamacro
1.Dooneofthefollowing:
∙Opentheworkbookthatcontainsthemacrothatyouwanttodelete.
∙Ifthemacrothatyouwanttodeleteisstoredinthepersonalmacroworkbook(Personal.xlsb),andthisworkbookishidden,dothefollowingtounhidetheworkbook:
1.OntheViewtab,intheWindowgroup,clickUnhide.
2.UnderUnhideworkbooks,clickPERSONAL,andthenclickOK.
2.IftheDevelopertabisnotavailable,dothefollowingtodisplayit:
1.ClicktheMicrosoftOfficeButton
andthenclickExcelOptions.
2.InthePopularcategory,underTopoptionsforworkingwithExcel,selecttheShowDevelopertabintheRibboncheckbox,andthenclickOK.
3.OntheDevelopertab,intheCodegroup,clickMacros.
4.IntheMacrosinlist,selecttheworkbookthatcontainsthemacrothatyouwanttodelete.Forexample,clickThisWorkbook.
5.IntheMacronamebox,clickthenameofthemacrothatyouwanttodelete.
6.ClickDelete.
TopofPage
Didthisarticlehelpyou?
Yes
No
NotwhatIwaslookingfor
(注:
可编辑下载,若有不当之处,请指正,谢谢!
)
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Excel 英文