Txhawm rau kom nkag mus rau cov ntaub ntawv nkag mus rau hauv lub rooj hauv Excel, koj tuaj yeem siv cov ntawv tshwj xeeb los pab ua kom cov txheej txheem ntawm kev sau lub rooj sib txig nrog cov ntaub ntawv. Excel muaj cov cuab yeej tsim muaj uas tso cai rau koj sau nrog cov qauv zoo sib xws. Tus neeg siv kuj tuaj yeem tsim nws tus kheej version ntawm daim ntawv, uas yuav ua kom haum rau nws cov kev xav tau, siv macro rau qhov no. Cia peb saib ntawm kev siv sib txawv ntawm cov sau cov cuab yeej muaj txiaj ntsig hauv Excel.
Siv cov cuab yeej sau
Daim foos foos yog ib qho khoom siv nrog cov teb uas nws cov npe sib haum nrog cov npe ntawm kab ntawv ntawm lub rooj yuav tau sau. Koj yuav tsum sau cov ntaub ntawv hauv cov teb no thiab lawv yuav raug ntxiv los ntawm kab tshiab rau cov kab ntau. Daim ntawv tuaj yeem ua raws li tus txheej txheem cais ua Excel, lossis nyob ncaj qha rau ntawm daim ntawv hauv daim ntawv ntawm nws qhov ntau, yog tias nws tau tsim los ntawm tus neeg siv.
Tam sim no cia saib seb yuav siv ob hom twj no li cas.
Txoj Kev 1: cov khoom tsim rov qab rau Excel cov tswv yim cov ntaub ntawv
Ua ntej tshaj plaws, cia peb kawm paub siv daim foos built-in kom nkag mus rau cov ntaub ntawv Excel.
- Nws yuav tsum raug sau tseg tias los ntawm lub neej ntawd lub cim uas nthuav tawm nws yog zais thiab xav tau kev ua haujlwm. Ua li no, mus rau ntawm lub tab Cov ntaub ntawvthiab nyem rau ntawm qhov khoom "Xaiv".
- Hauv qhib qhov rai Excel xaiv, tsiv mus rau ntu Txoj kev mus ceev ToolbarCov. Feem ntau ntawm lub qhov rais tau nyob ntawm ib cheeb tsam ntawm cov chaw teeb meem loj. Ntawm sab laug yog cov cuab yeej uas tuaj yeem muab ntxiv rau hauv cov txheej txheem nkag ceev, thiab ntawm sab xis - twb qhia tau tam sim no.
Hauv dab teb "Xaiv cov pab pawg los ntawm" teeb tus nqi "Pab pawg tsis nyob ntawm kab xev"Cov. Tom ntej no, los ntawm cov npe ntawm cov lus txib hauv kev sau npe niam txiv, peb nrhiav thiab xaiv txoj haujlwm "Daim Ntawv ..."Cov. Nyem ntawd tag khawm Ntxiv.
- Tom qab ntawd, qhov cuab tam peb xav tau yuav raug pom nyob ntawm sab xis ntawm lub qhov rais. Nyem rau feem khawm "OK".
- Tam sim no cov cuab yeej no tau nyob hauv Excel qhov rai ntawm lub vaj huam sib luag nkag tau sai, thiab peb tuaj yeem siv nws. Nws yuav nyob rau thaum qhib txhua phau ntawv ua haujlwm nrog qhov piv txwv ntawm Excel.
- Tam sim no, kom cov cuab yeej to taub qhov twg nws yuav tsum sau hauv, koj yuav tsum sau cov kab hauv qab ntawm lub rooj thiab sau txhua tus nqi hauv nws. Cia lub rooj qhov rooj nrog peb muaj plaub kab ntawv uas muaj npe "Khoom Npe", "Kom muaj nuj nqis", "Nqe" thiab "Tus nqi"Cov. Nkag mus rau cov ntaub ntawv lub npe hauv txoj kab ntawm kab zauv tav toj ntawm cov ntawv.
- Tsis tas li, rau qhov kev zov me nyuam kom nkag siab txog qhov twg nws yuav xav tau ua haujlwm nrog, koj yuav tsum nkag mus rau ib qho nqi ntawm thawj kab ntawm cov lus array.
- Tom qab ntawd, xaiv txhua lub xov tooj ntawm lub rooj seem thiab nyem rau ntawm lub cim hauv daim ntawv nkag ceev "Daim Ntawv ..."uas peb tau qhib ua ntej.
- Yog li, lub qhov rai ntawm lub cuab tam teev qhib. Raws li koj tuaj yeem pom, qhov khoom no muaj cov teb uas sib haum nrog cov kem npe ntawm peb cov lus array. Ntxiv mus, thawj daim teb yog twb sau nrog tus nqi, txij li peb nkag mus hauv nws tus kheej ntawm daim ntawv.
- Nkag mus rau qhov tseem ceeb uas peb xav tias tsim nyog hauv cov teb ntxiv, thiab tom qab ntawd nyem rau lub pob Ntxiv.
- Tom qab ntawd, raws li koj tuaj yeem pom, qhov nkag mus rau qhov tseem ceeb tau hloov mus rau thawj kab ntawm lub rooj, thiab hauv daim ntawv muaj kev hloov mus rau tom ntej thaiv ntawm cov teb, uas sib haum rau kab thib ob ntawm lub rooj array.
- Sau rau lub cuab yeej lub qhov rais nrog cov nqi uas peb xav pom hauv kab ob ntawm cov chaw ua noj, thiab nyem lub pob dua Ntxiv.
- Raws li koj tuaj yeem pom, tus nqi ntawm kab thib ob kuj tau ntxiv, thiab peb tsis tas yuav rov kho tus kheej li tus chij hauv lub rooj nws tus kheej.
- Yog li, peb sau cov kab ntawv rooj nrog txhua qhov txiaj ntsig uas peb xav nkag mus rau hauv nws.
- Ntxiv rau, yog qhov xav tau, koj tuaj yeem tshawb los ntawm cov txiaj ntsig yav dhau los siv cov khawm "Rov Qab" thiab "Tom ntej" lossis kab ntsug ntsug.
- Yog tias tsim nyog, koj tuaj yeem hloov kho txhua tus nqi hauv cov lus array los ntawm hloov nws hauv daim foos. Txhawm rau txhawm rau hloov pauv rau ntawm daim ntawv, tom qab ua lawv nyob rau hauv cov khoom sib txuas ntawm lub cuab yeej, nyem rau ntawm lub pob Ntxiv.
- Raws li koj tuaj yeem pom, qhov hloov tam sim ntawd tshwm sim hauv thaj chaw hauv qab rooj.
- Yog tias peb yuav tsum tau rho tawm txoj kab, tom qab dhau los ntawm cov kab qhia nyav lossis kab kos peb mus rau qhov chaw sib txuam nyob hauv daim foos. Tom qab ntawv, nyem rau ntawm lub pob Rho tawm nyob rau hauv lub cuab yeej qhov rai.
- Ib qho lus ceeb toom qhib, ceeb toom rau koj tias txoj kab yuav raug rho tawm. Yog tias koj ntseeg siab rau koj cov kev ua, ces nyem rau ntawm lub pob "OK".
- Raws li koj tuaj yeem pom, kab tau muab rho tawm los ntawm cov lus kab. Tom qab sau thiab kho tiav tiav, koj tuaj yeem tawm lub pob khoom siv los ntawm txhaj rau lub pob Kaw.
- Tom qab ntawd, muab lub rooj nthuav dav ua kom pom qhov pom kev zoo dua, kev tsim qauv tuaj yeem ua tiav.
Txoj Kev 2: tsim daim foos kev cai
Ib qho ntxiv, nrog kev pab ntawm macro thiab ib tug xov tooj ntawm lwm yam cuab yeej, nws muaj peev xwm los tsim koj tus kheej daim ntawv kev cai los sau rau lub rooj ua haujlwm. Nws yuav tsim ncaj qha rau ntawm daim ntawv, thiab yuav sawv cev rau nws ntau yam. Siv cov cuab yeej no, tus neeg siv nws tus kheej thiaj li yuav paub txog cov sijhawm uas nws pom tias tsim nyog. Nyob rau hauv cov nqe lus ntawm kev ua haujlwm, nws yuav nyob rau hauv tsis muaj txoj kev ua tsis tau zoo rau built-in Excel analogue, thiab hauv qee txoj kev nws yuav zoo dua rau nws. Lub tsuas tsis zoo yog tias rau txhua lub rooj teeb tsa koj yuav tsum tau sau ib daim ntawv cais, thiab tsis siv tib lub qauv, raws li muaj peev xwm ua tau thaum siv cov qauv version.
- Raws li nyob rau hauv txoj kev dhau los, ua ntej ntawm txhua yam, koj yuav tsum ua lub taub hau ntawm lub rooj yav tom ntej ntawm daim ntawv. Nws yuav muaj tsib lub npe nrog rau cov npe: "Tsis muaj.", "Khoom Npe", "Kom muaj nuj nqis", "Nqe", "Tus nqi".
- Tom ntej no, peb yuav tsum tau ua lub npe hu ua "ntse" los ntawm peb cov lus rooj, nrog lub peev xwm los tso kab txuas ntxiv thaum sau cov kab nyob ib sab lossis kab mob cov ntaub ntawv. Ua li no, xaiv lub header thiab, ua nyob rau hauv lub tab "Tsev"nyem rau ntawm lub pob "Format li rooj" hauv lub thawv Cov YeejCov. Qhov no qhib ib daim ntawv uas muaj cov kev xaiv style. Kev xaiv ntawm ib qho ntawm lawv yuav tsis cuam tshuam rau kev ua haujlwm hauv txhua txoj kev, yog li peb tsuas yog xaiv qhov kev xaiv uas peb txiav txim siab zoo dua.
- Tom qab ntawd lub qhov rais me me rau kev teeb tsa lub rooj qhib. Nws qhia txog qhov ntau uas peb tau faib ua ntej, uas yog, qhov ntau ntawm cov header. Raws li txoj cai, hauv daim teb no txhua yam yog sau kom raug. Tab sis peb yuav tsum kos lub thawv tom ntej ntawm qhov ntsuas Cov lus lub roojCov. Tom qab ntawv, nyem rau ntawm lub pob "OK".
- Yog li, peb cov ntau yam tau muab sau ua "rooj ntse", raws li muaj pov thawj pom los ntawm kev hloov pauv hauv cov teeb pom kev zoo. Raws li koj tuaj yeem pom, ntawm lwm yam, lim icon tshwm ib sab ntawm txhua kem nqe lus npe. Lawv yuav tsum muaj mob xiam oob qhab. Ua li no, xaiv txhua lub cell ntawm "ntse" rooj thiab mus rau lub tab "Cov ntaub ntawv"Cov. Muaj nyob rau txoj xov xov hauv lub thawv Txheeb thiab Lim nyem rau ntawm qhov icon "Lim".
Muaj lwm txoj hauv kev los txiav tawm lub lim. Hauv qhov no, nws yuav tsis tsim nyog hloov mus rau lwm lub tab, seem hauv seem tab "Tsev"Cov. Tom qab xaiv cov hlwb ntawm thaj chaw cov lus nyob ntawm txoj hlua ntawm daim ntawv qhia teeb tsa "Editing" nyem rau ntawm qhov icon Txheeb thiab LimCov. Hauv cov npe uas tshwm tawm, xaiv txoj haujlwm "Lim".
- Raws li koj tuaj yeem pom, tom qab qhov kev ua no, cov cim lim tau ploj ntawm lub taub hau ntawm lub rooj, raws li xav tau.
- Tom qab ntawd peb yuav tsum tsim cov ntaub ntawv nkag teb chaws nws tus kheej. Nws tseem yuav yog ib hom ntawm cov lus ntxhuav muaj ob kab ntawv. Cov kab npe ntawm cov khoom no yuav raug rau cov kem teev npe ntawm lub rooj tseem ceeb. Qhov uas tsis suav yog yog kab ntawv "Tsis muaj." thiab "Tus nqi"Cov. Lawv yuav tsis tuaj. Tus thawj yuav suav yog siv macro, thiab tus nqi thib ob yuav muab xam los ntawm kev thov tus qauv rau cov zauv sib npaug los ntawm tus nqi.
Hauv seem ob ntawm cov ntaub ntawv nkag teb chaws yog tsis nyob hauv tam sim no. Hais ncaj qha tom qab qhov tseem ceeb yuav tau nkag rau nws kom sau cov kab ntawm cov kab tseem ceeb ntawm lub rooj.
- Tom qab ntawd peb tsim ib qho ntxiv rooj me me. Nws yuav muaj ib kem thiab nws yuav muaj ib daim ntawv teev cov khoom lag luam uas peb yuav tso rau ntawm kab ntawv thib ob ntawm lub rooj tseem ceeb. Txog kev pom meej, lub cell nrog lub npe ntawm daim ntawv ("Cov Khoom Muag") tuaj yeem nrog cov xim.
- Tom qab ntawv xaiv thawj khoob ntawm lub xov tooj ntawm cov khoom siv nqi. Mus rau hauv lub tab "Cov ntaub ntawv"Cov. Nyem rau lub cim Cov Ntaub Ntawv Kev Tshawb Xyuasuas tau muab tso rau ntawm daim xov xov hauv lub thawv "Ua haujlwm nrog cov ntaub ntawv".
- Lub thawv pib siv tau pib. Nyem rau teb "Cov ntaub ntawv hom"twg sai rau "Tej nqi".
- Los ntawm cov kev xaiv qhib, xaiv txoj haujlwm Sau.
- Raws li koj tuaj yeem pom, tom qab ntawd, lub qhov rais rau kev kuaj xyuas cov ntsiab lus tso saib me ntsis hloov nws txoj kev teeb tsa. Ib daim teb ntxiv tau tshwm sim "Los Ntawm"Cov. Peb nyem rau ntawm lub cim sab xis rau nws sab laug khawm.
- Tom qab ntawd cov tswv yim xaiv lub qhov rai yuav raug txo kom tsawg. Xaiv cov npe ntawm cov ntaub ntawv uas tau muab tso rau ntawm daim ntawv hauv ib qho chaw ntxiv rooj nrog tus cursor thaum tuav tus nas laug khawm "Cov Khoom Muag"Cov. Tom qab ntawd, rov qab nyem rau lub cim sab xis rau sab xis ntawm thaj chaw uas qhov chaw nyob ntawm kab xaiv tau tshwm.
- Qhov no rov mus rau lub thawv cim rau kev nkag mus rau qhov tseem ceeb. Raws li koj tuaj yeem pom, cov kev sib koom tes ntawm cov xaiv tau xaiv hauv nws twb qhia rau hauv lub tshav pob "Los Ntawm"Cov. Nyem rau feem khawm "OK" nyob hauv qab ntawm lub qhov rais.
- Tam sim no, mus rau sab xis ntawm kev xaiv ntawm tes ntawm cov ntaub ntawv nkag khoom, ib daim duab peb sab icon tau tshwm sim. Thaum koj nyem rau ntawm nws, daim ntawv teev npe qhib, uas muaj cov npe uas tau rub tawm los ntawm lub rooj array "Cov Khoom Muag"Cov. Tam sim no tsis tuaj yeem nkag mus rau cov ntaub ntawv tsis txaus siab rau hauv lub xovtooj qhia, tab sis koj tsuas tuaj yeem xaiv txoj haujlwm xav tau los ntawm daim ntawv tshaj tawm. Xaiv ib yam nyob rau hauv daim ntawv teev cia.
- Raws li koj tuaj yeem pom, txoj haujlwm raug xaiv tau tshwm sim tam sim ntawd hauv daim teb "Khoom Npe".
- Tom ntej no, peb yuav xav tso npe rau hauv peb lub hlwb ntawm cov ntawv pov thawj uas peb yuav sau cov ntaub ntawv. Xaiv thawj lub xov tooj ntawm tes, qhov twg lub npe tau raug teeb tsa hauv peb kis "Qos"Cov. Tom ntej no, mus rau thaj tsam lub npe. Nws nyob ntawm sab laug sab laug ntawm Excel qhov rais ntawm tib theem li tus txheej txheem ntsuas phom. Sau lub npe arbitrary muaj. Nws tuaj yeem yog txhua lub npe hauv Latin, uas tsis muaj chaw, tab sis nws yog qhov zoo dua los siv cov npe uas nyob ze rau cov haujlwm uas daws tau los ntawm cov khoom no. Yog li no, thawj lub cell, uas muaj lub npe ntawm cov khoom, yog hu ua "Npe"Cov. Peb sau lub npe no hauv thaj teb thiab nias tus yuam sij Sau ntawm cov keyboard.
- Tib txoj kev peb muab lub npe rau lub cell uas peb yuav nkag mus rau qhov ntau ntawm cov khoom lag luam "Volum".
- Thiab ntawm tes nrog tus nqi - "Nqe".
- Tom qab ntawd, hauv tib txoj kev peb muab lub npe rau tag nrho cov kab ntawm peb lub hlwb saum toj no. Ua ntej tshaj plaws, xaiv, thiab tom qab ntawd muab nws lub npe rau hauv qhov tshwj xeeb. Caws nws lub npe "Diapason".
- Tom qab qhov kev txiav txim zaum kawg, peb yuav tsum khaws cov ntawv cia kom cov npe uas peb tau tso npe tuaj yeem pom los ntawm macro uas peb tsim yav tom ntej. Yuav kom txuag tau, mus rau hauv lub tab Cov ntaub ntawv thiab nyem rau ntawm qhov khoom "Tseg Raws Li ...".
- Hauv qhov rai txuag uas qhib, hauv qhov chaw Hom Ntawv xaiv tus nqi "Excel Macro Txhawb nqa Phau Ntawv (.xlsm)"Cov. Ntxiv mus, nyem rau ntawm lub pob Txuag.
- Tom qab ntawd koj yuav tsum qhib lub macros hauv koj li version ntawm Excel thiab pab kom tab "Tus tsim tawm"yog tias koj tseem tsis tau. Qhov tseeb yog tias ob qho ntawm cov haujlwm no yog kev xiam oob qhab los ntawm lub program, thiab lawv kev ua kom zoo yuav tsum ua lub zog hauv Excel qhov rai.
- Tom qab koj tau ua tiav qhov no, mus rau hauv lub tab "Tus tsim tawm"Cov. Nyem rau ntawm qhov loj icon "Pom Qhov Muag Pom Zoo"nyob rau txoj hlua xov hauv lub thawv "Tus lej".
- Qhov kawg nkaus ua rau VBA macro editor pib. Hauv cheeb tsam "Project", uas yog nyob rau sab qaum kev sab sauv ntawm lub qhov rais, xaiv lub npe ntawm cov ntawv uas peb cov ntxhuav nyob. Hauv qhov no, nws yog "Ntawv 1".
- Tom qab ntawd, mus rau sab qaum qis hauv qab ntawm lub qhov rais hu ua "Khoom"Cov. Nov yog cov chaw ntawm daim ntawv xaiv. Hauv dab teb "(Npe)" Lub npe Cyrillic yuav tsum hloov ("Sheet1") nyob rau hauv lub npe sau ua lus Latin. Koj tuaj yeem muab txhua lub npe uas yooj yim dua rau koj, qhov tseem ceeb tshaj plaws yog tias nws tsuas muaj cov cim Latin lossis cov naj npawb thiab tsis muaj lwm yam phiajcim lossis chaw. Nws muaj nrog lub npe no tias macro yuav ua haujlwm. Cia peb qhov xwm txheej no lub npe yuav "Khoom", txawm hais tias koj tuaj yeem xaiv lwm yam uas muaj raws li cov kev mob tau piav qhia saum toj no.
Hauv dab teb "Npe" Koj tuaj yeem muab lub npe hloov nrog qhov yooj yim dua. Tab sis qhov no tsis tsim nyog. Hauv qhov no, kev siv cov chaw, Cyrillic thiab lwm cov cim raug tso cai. Tsis zoo li ntsuas dhau los, uas teev cov npe ntawv rau cov program, cov lus no pov thawj ib lub npe rau daim ntawv uas pom tau rau cov neeg siv hauv txoj kab shortcut.
Raws li koj tau pom, tom qab ntawd lub npe tseem yuav cia li hloov Daim Ntawv 1 hauv tshav pob "Project", rau ib qhov peb tsuas yog teeb tsa hauv cov chaw teeb tsa.
- Tom qab ntawd mus rau ntawm thaj chaw nruab nrab ntawm lub qhov rais. Nov yog qhov uas peb yuav tau sau cov cim loj dua. Yog hais tias daim teb ntawm tus lej code dawb hauv qhov chaw tau qhia tsis raug nthuav tawm, xws li hauv peb cov ntaub ntawv, tom qab ntawd nias tus haujlwm yuam F7 thiab nws yuav tshwm sim.
- Tam sim no rau qhov piv txwv tshwj xeeb, peb yuav tsum sau cov cai hauv qab no hauv daim teb:
Sub DataEntryForm ()
Txo kab tom ntej ntev npaum li cas
nextRow = Producty.Cells (Producty.Rows.Count, 2) .Qhov (xlUp). Offset (1, 0) .Txoj
Nrog khoom
Yog .Range ("A2"). Tus nqi = "" Thiab .Range ("B2"). Tus nqi = "" Tom qab
nextRow = nextRow - 1
Xaus yog
Producty.Range ("Lub Npe")
.Cells (nextRow, 2) .PasteSpecial Paste: = xlPasteValues
.Cells (nextRow, 3) .Value = Producty.Range ("Volum"). Tus nqi
.Cells (nextRow, 4) .Value = Producty.Range ("Nqe"). Tus nqi
.Cells (nextRow, 5) .Value = Producty.Range ("Volum"). Tus nqi * Cov khoom lag luam.Range ("Nqe"). Tus nqi
.Range ("A2"). Cov qauv = "= IF (ISBLANK (B2)," "" ", COUNTA ($ B $ 2: B2))"
Yog hais tias nextRow> 2 Tom qab ntawd
Cov Khwv ("A2"). Xaiv
Xaiv.AutoFill Lo Lus Kawg: = Ntau Yam ("A2: A" & nextRow)
Cov Khwv ("A2: A" & nextRow) .Xaiv
Xaus yog
.Range ("Diapason"). Cov ntsiab lus ntshiab
Xaus nrog
Xaus subTab sis cov cai no tsis yog universal, uas yog, nws yog qhov hloov pauv tsis haum rau peb rooj plaub. Yog tias koj xav hloov nws kom haum koj cov kev xav tau, ces nws yuav tsum tau hloov kho kom raug. Yog li koj tuaj yeem ua koj tus kheej, cia saib seb cov cai no muaj dab tsi, dab tsi yuav tsum tau hloov, thiab dab tsi yuav tsum tsis txhob hloov.
Yog li thawj kab:
Sub DataEntryForm ()
"Cov ntaub ntawvEntryForm" yog lub npe ntawm macro nws tus kheej. Koj tuaj yeem tso nws tawm raws li nws yog, lossis koj tuaj yeem hloov nws nrog lwm yam uas ua raws li cov kev cai dav dav rau kev tsim cov npe macro (tsis muaj chaw nyob, tsuas yog siv cov tsiaj ntawv ntawm Latin cov tsiaj ntawv, thiab lwm yam). Hloov lub npe yuav tsis cuam tshuam dab tsi.
Cov ntsiab lus tshwm sim hauv tus lej "Khoom" koj yuav tsum hloov nws nrog lub npe uas koj yav dhau los muab koj daim ntawv tso rau hauv lub tshav pob "(Npe)" thaj chaw ntawm "Khoom" macro editor. Lawm, qhov no yuav tsum tau ua yog koj sau lub npe rau hauv txoj kev sib txawv.
Tam sim no xav txog kab no:
nextRow = Producty.Cells (Producty.Rows.Count, 2) .Qhov (xlUp). Offset (1, 0) .Txoj
Txawb "2" nyob rau hauv kab no txhais tau tias yog pawg thib ob ntawm daim ntawv. Kab ntawv no yog kem "Khoom Npe"Cov. Ntawm nws peb yuav suav tus naj npawb ntawm cov kab. Yog li ntawd, yog tias nyob hauv koj kis muaj kem zoo sib xws muaj qhov sib txawv hauv tus as khauj, tom qab ntawd koj yuav tsum sau tus lej xov tooj uas raug. Tus nqi "Xaus (xlUp) .Offset (1, 0) .Txiav" nyob rau hauv txhua rooj plaub, tawm tsis hloov.
Tom ntej, xav txog kab
Yog .Range ("A2"). Tus nqi = "" Thiab .Range ("B2"). Tus nqi = "" Tom qab
"A2" - Cov no yog qhov ua haujlwm ntawm thawj lub xovtooj ntawm kab twg hauv tus lej kab. "B2" - Cov no yog qhov ua haujlwm ntawm thawj lub cell los ntawm cov ntaub ntawv twg yuav tawm ("Khoom Npe") Yog tias lawv sib txawv, sau koj cov ntaub ntawv es tsis txhob ua cov chaw sib koom tes no.
Mus rau kab
Producty.Range ("Lub Npe")
Nws muaj qhov ntsuas tawm "Npe" txhais lub npe uas peb tau muab rau lub teb "Khoom Npe" hauv cov ntawv foos.
Hauv kab
.Cells (nextRow, 2) .PasteSpecial Paste: = xlPasteValues
.Cells (nextRow, 3) .Value = Producty.Range ("Volum"). Tus nqi
.Cells (nextRow, 4) .Value = Producty.Range ("Nqe"). Tus nqi
.Cells (nextRow, 5) .Value = Producty.Range ("Volum"). Tus nqi * Cov khoom lag luam.Range ("Nqe"). Tus nqinpe "Volum" thiab "Nqe" txhais tau cov npe peb tau muab rau daim teb "Kom muaj nuj nqis" thiab "Nqe" hauv tib cov ntawv nkag.
Ntawm tib kab uas peb tau qhia saum toj no, cov naj npawb "2", "3", "4", "5" txhais hais tias tus naj npawb kem hauv Daim Ntawv Excel ua tau raws seem "Khoom Npe", "Kom muaj nuj nqis", "Nqe" thiab "Tus nqi"Cov. Yog li ntawd, yog tias koj rooj plaub lub rooj hloov pauv, tom qab ntawd koj yuav tsum qhia cov xov tooj ntawm kab xov tooj kom haum. Yog tias muaj ntau cov kab ntawv ntxiv, tom qab ntawd los ntawm kev sib piv koj yuav tsum ntxiv nws txoj kab rau tus lej, yog tias tsawg dua - tom qab ntawd tshem cov ntxiv.
Cov kab khoo cov khoom sib txawv los ntawm nws cov nqi:
.Cells (nextRow, 5) .Value = Producty.Range ("Volum"). Tus nqi * Cov khoom lag luam.Range ("Nqe"). Tus nqi
Qhov txiaj ntsig, zoo li peb pom los ntawm cov ntawv cim ntawm cov ntawv, yuav ua kom pom hauv kab ntawv thib tsib ntawm Excel Daim ntawv.
Cov lus qhia no ua kab tsis siv neeg kab:
Yog hais tias nextRow> 2 Tom qab ntawd
Cov Khwv ("A2"). Xaiv
Xaiv.AutoFill Lo Lus Kawg: = Ntau Yam ("A2: A" & nextRow)
Cov Khwv ("A2: A" & nextRow) .Xaiv
Xaus yogTxhua qhov tseem ceeb "A2" txhais tau qhov chaw nyob ntawm tus xovtooj ntawm thawj zaug uas tus lej yuav raug ua, thiab cov kev sib koom tes "A " - Qhov chaw nyob ntawm kem tag nrog tus lej. Kuaj qhov twg tus lej yuav raug tso tawm hauv koj lub rooj thiab hloov cov chaw ua haujlwm no hauv txoj cai, yog tias tsim nyog.
Cov kab ntxuav tawm ntawm thaj tsam ntawm cov ntaub ntawv nkag teb chaws tom qab cov ntaub ntawv los ntawm nws tau hloov mus rau lub rooj:
.Range ("Diapason"). Cov ntsiab lus ntshiab
Nws tsis nyuaj rau kwv yees tias ("Diapason") txhais tau lub npe ntawm qhov ntau uas peb yav tas los muab rau cov ntaub ntawv nkag teb. Yog tias koj tau muab lawv lub npe txawv, tom qab ntawd cov kab ntawv no yuav tsum tso rau qhov ntawd.
Ib qho txuas ntxiv ntawm txoj cai yog kev siv thoob ntiaj teb thiab hauv txhua kis yuav qhia yam tsis muaj kev hloov pauv.
Tom qab koj tau kaw macro code hauv lub editor qhov rais, nyem rau ntawm txuag lub icon nyob rau hauv daim ntawv ntawm diskette nyob rau sab laug ntawm lub qhov rais. Tom qab ntawd koj tuaj yeem kaw nws los ntawm txhaj khawm tus qauv khawm rau kaw qhov rais hauv kaum tsev sab sauv.
- Tom qab ntawd, peb rov mus rau hauv Excel daim ntawv. Tam sim no peb yuav tsum tso lub khawm uas yuav ua kom lub macro tsim. Ua li no, mus rau ntawm lub tab "Tus tsim tawm"Cov. Hauv cov chaw thaiv "Tswj" rau ntawm txoj hlua khi, nyem rau ntawm lub pob Muab tshuaj txhuamCov. Daim ntawv teev cov cuab yeej qhib. Ntawm pab pawg "Daim Ntawv Tswj" xaiv thawj tug - Khawm.
- Tom qab ntawd, nrog tus nas laug khawm nyem, kos tus cim rau ntawm thaj chaw uas peb xav tso lub pob macro ua ntej qhib, uas yuav hloov cov ntaub ntawv los ntawm daim ntawv mus rau lub rooj.
- Tom qab thaj chaw ncig, tso cov nas khawm. Tom qab ntawd, macro assign window rau cov kwv pib cia. Yog tias ob peb macros siv nyob rau hauv koj phau ntawv, tom qab ntawd xaiv lub npe ntawm ib qho peb tsim saum toj no los ntawm daim ntawv. Peb hu nws "Cov ntaub ntawvEntryForm"Cov. Tab sis qhov no, macro yog ib qho, yog li cia li xaiv nws thiab nyem rau ntawm lub pob "OK" nyob hauv qab ntawm lub qhov rais.
- Tom qab ntawd, koj tuaj yeem hloov npe khawm raws li koj xav tau, tsuas yog los ntawm nws lub npe tam sim no.
Hauv peb qhov teebmeem, piv txwv, nws yog ib lub laj thawj los muab nws lub npe NtxivCov. Hloov npe thiab nyem rau ntawm txhua lub xovtooj dawb nyob hauv daim ntawv.
- Yog li, peb daim foos tau npaj tiav. Cia peb kuaj xyuas seb nws ua haujlwm. Nkag mus rau qhov tseem ceeb tsim nyog hauv nws daim teb thiab nyem rau ntawm lub pob Ntxiv.
- Raws li koj tuaj yeem pom, cov nqi raug hloov mus rau lub rooj, cov kab tau muab tus lej txiav ib tus lej, tus nqi raug txiav txim, cov foos daim foos raug tshem tawm.
- Rov ua daim ntawv no thiab nyem rau ntawm lub pob Ntxiv.
- Raws li koj tuaj yeem pom, kab thib ob kuj tseem ntxiv rau cov lus hauv rooj. Qhov no txhais tau tias cov cuab yeej ua haujlwm.
Nyeem kuj:
Yuav ua li cas los tsim cov macro hauv Excel
Yuav ua li cas los tsim lub pob hauv Excel
Hauv Excel, nws muaj ob txoj hauv kev los siv cov ntaub ntawv sau daim ntawv: ua hauv thiab siv neeg txhais. Siv qhov kev xaiv ua-nyob rau hauv yuav tsum tau siv zog tsawg kawg los ntawm tus neeg siv. Koj muaj peev xwm ib txwm tso nws los ntawm kev ntxiv tus yam ntxwv icon rau tus txheej txheem nkag ceev cov toolbar. Koj yuav tsum tsim ib daim ntawv foos ntawm koj tus kheej, tab sis yog tias koj paub zoo hauv VBA code, koj tuaj yeem ua qhov cuab yeej no hloov tau thiab haum rau koj cov kev xav tau.