Yuav Paub
- Six tus tswv: sib npaug (=), ntau dua (>), tsawg dua (<), ntau dua lossis sib npaug rau (>= ) tsawg dua lossis sib npaug rau (<= ), tsis sib npaug ().
- Kev sib piv tus neeg siv ntau tshaj plaws yog nyob rau hauv IF ua haujlwm.
Kab lus no piav qhia yuav ua li cas siv cov neeg ua haujlwm sib piv I=hauv Excel. Cov lus qhia siv rau Excel versions 2019, 2016, 2013, 2010, Excel Online, thiab Excel rau Mac.
Six Comparison Operators
Muaj rau tus neeg ua haujlwm sib piv muaj rau koj siv hauv Excel.
Cov neeg ua haujlwm no yog siv los ntsuas rau cov xwm txheej xws li:
- Equal: Ob qhov tseem ceeb lossis txoj hlua zoo ib yam (apple =apple)
- Ntau dua: Ib tus nqi loj dua lwm qhov (10 >8)
- Less Than: Ib tus nqi me dua li lwm tus (8 <10)
- Ntau dua lossis sib npaug rau: Ib tus nqi loj dua lossis tib yam li lwm tus (10 >=10)
- Less than or Equal To: Ib tus nqi me dua los yog tib yam li lwm tus (5 <=5)
- Tsis sib npaug: Ob qhov txiaj ntsig tsis zoo ib yam (dub miv)
Txhua tus neeg ua haujlwm sib piv ua haujlwm nrog qhov tseem ceeb, thaum qee qhov (xws li thiab =) kuj ua haujlwm nrog cov hlua (ntawv nyeem) thiab hnub.
Sib piv cov neeg ua haujlwm hauv IF Function
Muaj ob qhov chaw hauv Excel uas koj tuaj yeem siv cov neeg ua haujlwm sib piv. Kev siv ntau tshaj plaws yog sab hauv ntawm IF ua haujlwm.
Hauv ib lub xovtooj ntawm daim ntawv nthuav qhia, hu rau IF muaj nuj nqi los ntawm kev ntaus ntawv:
Koj yuav pom cov ntawv pab pop-up uas nyeem:
Nov yog hom kev siv IF ua haujlwm kom raug.
- Thawj tus nqi yog qhov kev ntsuas raws cai uas muaj tus neeg teb xov tooj sib piv.
- Tus nqi thib ob yog tus lej lossis txoj hlua uas koj xav tau tso tawm yog tias qhov sib piv yog qhov tseeb.
- Tus nqi thib peb yog tus lej lossis txoj hlua uas koj xav tau tso tawm yog tias qhov sib piv tsis tseeb.
Txhua peb qhov tseem ceeb hauv IF muaj nuj nqi yuav tsum tau muab cais nrog commas.
Qhov kev sim ntsuas muaj peev xwm hais txog qhov tseem ceeb lossis cov hlwb hauv Excel daim ntawv nthuav qhia uas muaj qhov tseem ceeb. Koj tseem tuaj yeem zes cov qauv hauv qhov sib piv nws tus kheej.
Piv txwv li, los sib piv cov ntaub ntawv hauv cell A1 rau cov ntaub ntawv hauv cell B4, hom:
Kom xyuas seb tus nqi hauv cell A1 qis dua 50, hom:
txhawm rau txheeb xyuas seb tus nqi hauv cell A1 tsawg dua li ib nrab tus nqi hauv cell B4, hom:
Hauv cov piv txwv saum toj no, Excel rov qab yog qhov tseeb lossis FALSE hauv lub xov tooj ntawm tes uas koj tau ntaus ntawv IF, nyob ntawm qhov tshwm sim ntawm qhov sib piv.
Koj tuaj yeem hloov qhov tseeb lossis FALSE nrog tus nqi lossis txoj hlua yog tias koj xav tau cov qauv IF rov qab ua lwm yam hauv lub xovtooj ntawd. Piv txwv li:
Qhov no yuav rov "Bob" hauv lub xov tooj yog tias qhov xwm txheej muaj tseeb, lossis "Sally" yog qhov xwm txheej tsis tseeb.
Sib piv cov neeg ua haujlwm hauv Excel VBA lossis Macros
Koj tuaj yeem siv tib tus neeg ua haujlwm sib piv hauv Excel VBA editor.
Excel VBA yog siv los tsim macros rau automating kev ua hauv daim ntawv nthuav qhia.
Txhawm rau qhib Excel VBA editor:
- Xaiv File > Options > Customize Ribbon.
- Enable the Developer check box hauv qab Main Tabs thiab xaiv OK.
- In Excel, xaiv Developer > View Code.
- Double-click ThisWorkbook hauv qab Microsoft Excel Objects nyob rau sab laug pane.
- Nyob rau sab saum toj ntawm lub qhov rais code, teeb tsa sab laug rau Workbook thiab sab xis rau Open.
Tam sim no koj tab tom kho cov lej uas yuav khiav txhua zaus qhib cov ntaub ntawv Excel. Hauv qhov rai no, koj tuaj yeem sib piv ntawm tes A1 rau A2, thiab cia li sau rau hauv A3 nrog tus nqi lossis cov ntawv nyob ntawm tus neeg teb xov tooj sib piv.
Ntawm no yog ib qho piv txwv ntawm qhov code yuav zoo li:
If [A1] < [A2] Then
[A3]="YES"
Else
[A3]="NO"
End Yog
Kev sib txawv me ntsis hauv VBA, tab sis cov cim kev sib piv (tus neeg ua haujlwm) siv los sib piv ob qhov tseem ceeb lossis cov hlua yog tib yam.