Ama-macros akwa-Microsoft Excel angasheshisa kakhulu umsebenzi namadokhumenti kulo mhleli wesipredishithi. Lokhu kutholakala ngokuzenzakalela izenzo eziphindaphindiwe ezibhalwe kukhodi ekhethekile. Ake sibheke indlela yokudala ama-macros ku-Excel, nokuthi angalungiswa kanjani.
Izindlela Zokurekhoda Ama-Macros
Ama-Macros angabhalwa ngezindlela ezimbili:
- ngokuzenzakalelayo;
- ngesandla.
Ukusebenzisa ukhetho lokuqala, umane urekhode izenzo ezithile ku-Microsoft Excel oyenzayo ngesikhathi esinikeziwe. Khona-ke, ungadlala leli rekhodi. Le ndlela ilula kakhulu, futhi ayidingi ulwazi lwekhodi, kepha ukusebenza kwayo okusebenzayo kunomkhawulo.
Ukurekhoda kwama-macros ngokubhaliwe, ngokuphambene nalokho, kudinga ulwazi lohlelo, ngoba ikhodi ifakwe ngesandla kusuka kwikhibhodi. Kodwa, ikhodi ebhaliwe kahle ngale ndlela ingashesha kakhulu ukukwenziwa kwezinqubo.
Ukuqopha okuzenzakalelayo kwe-Macro
Ngaphambi kokuba uqale ukurekhoda okuzenzakalelayo kwama-macros, udinga ukunika amandla ama-macros ku-Microsoft Excel.
Okulandelayo, iya kuthebhu "Developer". Chofoza inkinobho ethi "I-Macro Record", esitholakala kutheyipu ku-"Code" block block.
Ifasitela yezilungiselelo zokuqopha macro ivula. Lapha ungacacisa noma yiliphi igama le-macro uma okuzenzakalelayo akuhambisani nawe. Into esemqoka ukuthi igama liqala ngencwadi, hhayi inombolo. Futhi, akumele kube khona izikhala esihlokweni. Sishiye igama elizenzakalelayo - "Macro1".
Lapha, uma ufisa, ungasetha ukhiye wezinqamuleli, uma uchofoziwe, i-macro izokwethulwa. Ukhiye wokuqala kufanele ube ukhiye we-Ctrl, futhi ukhiye wesibili usethe umsebenzisi ngokwakhe. Isibonelo, thina, njengesibonelo, usethe ukhiye M.
Okulandelayo, udinga ukubona ukuthi i-macro izogcinwa kuphi. Ngokuzenzakalelayo, lizogcinwa encwadini efanayo (ifayela), kodwa uma ufisa, ungabeka isitoreji encwadini entsha, noma encwadini ehlukile yama-macros. Sizoshiya inani elizenzakalelayo.
Esikhathini esisezingeni eliphansi kunazo zonke zokubeka, ungashiya noma iyiphi incazelo ehambisana nomongo yale macro. Kodwa akudingekile ukwenza lokhu.
Uma zonke izilungiselelo zenziwa, chofoza inkinobho ethi "Kulungile".
Emva kwalokho, zonke izenzo zakho kule ncwadi ye-Excel (ifayela) izorekhodwa kwi-macro uze umeke ukuziqopha ngokwakho.
Isibonelo, sibhala isenzo se-arithmetic esilula: ukwengezwa kokuqukethwe kwamaseli amathathu (= C4 + C5 + C6).
Emva kwalokho, chofoza inkinobho ethi "Yeka ukurekhoda". Le nkinobho yaguqulwa kusuka inkinobho ethi "Rekhoda Macro", ngemuva kokurekhoda kusebenziwe.
Run Macro
Ukuze uhlole ukuthi i-macro eqoshiwe isebenza kanjani, chofoza inkinobho ye-Macros ku-Barcode yamathuluzi efanayo, noma cindezela inhlanganisela yekhi ye-Alt + F8.
Ngemuva kwalokho, ifasiteleni ivula uhlu lwamacros aqoshiwe. Sifuna i-macro esiyibhalile, ukhethe, bese uchofoza inkinobho ethi "Run".
Ungenza ngisho nokulula, futhi ungabize ngisho newindi lokukhetha elibanzi. Siyakhumbula ukuthi sibhale inhlanganisela ye "okhiye abashisayo" wekholi ye-macro esheshayo. Esikhathini sethu, lokhu kuyiCtrl + M. Siyiphayipha le nhlanganisela kwikhibhodi, emva kwalokho i-macro igijima.
Njengoba ungabona, i-macro yenza kahle lezo zenzo ezilotshwe ngaphambili.
Ukuhlelwa kwe-Macro
Ukuze uhlele i-macro, phinda uchofoze inkinobho ethi "Macros". Ewindini evula, khetha i-macro oyifunayo, bese uchofoza inkinobho ethi "Hlela".
I-Microsoft Visual Basic (VBE) ivula - indawo lapho ama-macros ahlelwa khona.
Ukurekhodwa kwe-macro ngayinye kuqala ngomyalo ophansi, futhi kuphetha ngomyalo wokugcina we-End. Masinyane emva komyalo ophansi, igama elikhulu licacisiwe. Opharetha "Range (" ... "). Khetha" kubonisa ukhetho lweseli. Isibonelo, uma umyalo othi "Range (" C4 "). Khetha" kukhethwe iseli C4. Opharetha "ActiveCell.FormulaR1C1" isetshenziselwa ukurekhoda izenzo ngamafomula, nakwezinye izibalo.
Ake sizame ukushintsha i-macro kancane. Ukwenza lokhu, sengeza inkulumo kwi-macro:
Ibanga ("C3"). Khetha
I-ActiveCell.FormulaR1C1 = "11"
Inkulumo ethi "ActiveCell.FormulaR1C1 =" = R [-3] C + R [-2] C + R [-1] C "" ithathelwe "ActiveCell.FormulaR1C1 =" = R [-4] C + R [-3 ] C + R [-2] C + R [-1] C "".
Vala umhleli, futhi usebenzise i-macro, njengesikhathi sokugcina. Njengoba ubona, ngenxa yezinguquko esizifakile, enye iseli yedatha yengezwe. Wabuye wabalwa ekubalweni kwenani eliphelele.
Uma kwenzeka i-macro inkulu kakhulu, ukubulawa kwayo kungathatha isikhathi esiningi. Kodwa, ngokwenza ushintsho olwenziwe kukhokhodi, singasheshisa inqubo. Engeza umyalo othi "Isicelo.ScreenUpdating = Amanga". Kuzokuvumela ukuba ulondoloze amandla okusebenzisa i-computing, futhi ngaleyo ndlela usheshise umsebenzi. Lokhu kufezwa ngokulahla ukuvuselela isikrini ngenkathi kwenziwa izinyathelo zokufunda. Ukuze ubuyekeze isibuyekezo ngemuva kokusebenzisa i-macro, ekupheleni kwalo bhala umyalo othi "Isicelo.ScreenUpdating = True"
Siphinde sengeze umyalo othi "Ukusebenza.Ukuqalwa = xlUkuqalwaManual" ekuqaleni kwekhodi, futhi ekupheleni kwekhodi sinezela "Isicelo.Ukuqalwa = xlCalculationAutomatic". Ngalokhu sivimbela kuqala ukulungiswa okuzenzekelayo komphumela ngemva kokushintsha kwamaseli ngayinye, futhi ukuyivula ekugcineni kwe-macro. Ngakho-ke, i-Excel izobala umphumela kanye kuphela, futhi ngeke iphinde ibuye kabusha, okuzogcina isikhathi.
Ukubhala ikhodi ye-macro kusukela ekuqaleni
Abasebenzisi abathuthukile abakwazi kuphela ukuhlela nokwandisa ama-macros aqoshiwe, kodwa futhi baqophe ikhodi ye-macro kusukela ekuqaleni. Ukuze uqhubeke nalokhu, udinga ukuchofoza inkinobho ethi "Visual Basic", etholakala ekuqaleni kwebheboni yonjiniyela.
Ngemuva kwalokho, iwindi le-VBE editor window livula.
Umqambi ubhala ikhodi macro khona ngesandla.
Njengoba ubona, ama-macros ku-Microsoft Excel angasheshisa ngokuphawulekayo ukuqhutshwa kwezinqubo ezivamile kanye nezinhlelo ezizimele. Kodwa, ezimweni eziningi, ngaleyo njongo, ama-macros afaneleka kakhulu, ikhodi yalo ebhaliwe ngesandla, hhayi izenzo eziqoshiwe ngokuzenzakalelayo. Ngaphezu kwalokho, ikhodi ye-macro ingahle ihlelwe ngumbhali we-VBE ukusheshisa inqubo yokwenza umsebenzi.