MS Excel: How To Use The OR Function (VBA) - TechOnTheNet
Có thể bạn quan tâm
- Home
- MS Excel
- Formulas / Functions
MS Excel: How to use the OR Function (VBA) This Excel tutorial explains how to use the Excel OR function (in VBA) with syntax and examples.
Description
The Microsoft Excel OR function returns TRUE if any of the conditions are TRUE. Otherwise, it returns FALSE.
The OR function is a built-in function in Excel that is categorized as a Logical Function. It can be used as a VBA function (VBA) in Excel. As a VBA function, you can use this function in macro code that is entered through the Microsoft Visual Basic Editor.
Please read our OR function (WS) page if you are looking for the worksheet version of the OR function as it has a very different syntax.
Syntax
The syntax for the OR function in Microsoft Excel is:
condition1 Or condition2 [... Or condition_n] )Parameters or Arguments
condition1, condition2, ... condition_n Expressions that you want to test that can either be TRUE or FALSE.Returns
The OR function returns TRUE if any of the conditions are TRUE. The OR function returns FALSE if all conditions are FALSE.
Applies To
- Excel for Office 365, Excel 2019, Excel 2016, Excel 2013, Excel 2011 for Mac, Excel 2010, Excel 2007, Excel 2003, Excel XP, Excel 2000
Type of Function
- VBA function (VBA)
Example (as VBA Function)
The OR function with this syntax can only be used in VBA code in Microsoft Excel.
Let's look at some Excel OR function examples and explore how to use the OR function in Excel VBA code.
This first example combines the OR function with the IF Statement in VBA:
If LWebsite = "TechOnTheNet.com" Or LCount > 25 Then LResult = "Great" Else LResult = "Fair" End IfThis would set the LResult variable to the string value "Great" if either LWebsite was "TechOnTheNet.com" or LCount > 25. Otherwise, it would set the LResult variable to the string value "Fair".
You can use the OR function with the AND function in VBA, for example:
If (LWebsite = "TechOnTheNet.com" Or LWebsite = "CheckYourMath.com") And LPages <= 10 Then LBandwidth = "Low" Else LBandwidth = "High" End IfThis would set the LBandwidth variable to the string value "Low" if LWebsite was either "TechOnTheNet.com" or "CheckYourMath.com" and LPages <= 10. Otherwise, it would set the LBandwidth variable to the string value "High".
Share on:Databases
- SQL
- Oracle / PLSQL
- SQL Server
- MySQL
- MariaDB
- PostgreSQL
- SQLite
MS Office
- Excel
- Access
- Word
Web Development
- HTML
- CSS
- JavaScript
- Color Picker
Programming
- C Language
More
- ASCII
- Unicode
- Linux
- UNIX
- Techie Humor

Lookup/Ref Functions
- ADDRESS (WS)
- AREAS (WS)
- CHOOSE (WS, VBA)
- COLUMN (WS)
- COLUMNS (WS)
- HLOOKUP (WS)
- HYPERLINK (WS)
- INDEX (WS)
- INDIRECT (WS)
- LOOKUP (WS)
- MATCH (WS)
- OFFSET (WS)
- ROW (WS)
- ROWS (WS)
- TRANSPOSE (WS)
- VLOOKUP (WS)
- XLOOKUP (WS)

String/Text Functions
- ASC (VBA)
- BAHTTEXT (WS)
- CHAR (WS)
- CHR (VBA)
- CLEAN (WS)
- CODE (WS)
- CONCAT (WS)
- CONCATENATE (WS)
- CONCATENATE with & (WS, VBA)
- DOLLAR (WS)
- EXACT (WS)
- FIND (WS)
- FIXED (WS)
- FORMAT STRINGS (VBA)
- INSTR (VBA)
- INSTRREV (VBA)
- LCASE (VBA)
- LEFT (WS, VBA)
- LEN (WS, VBA)
- LOWER (WS)
- LTRIM (VBA)
- MID (WS, VBA)
- NUMBERVALUE (WS)
- PROPER (WS)
- REPLACE (WS)
- REPLACE (VBA)
- REPT (WS)
- RIGHT (WS, VBA)
- RTRIM (VBA)
- SEARCH (WS)
- SPACE (VBA)
- SPLIT (VBA)
- STR (VBA)
- STRCOMP (VBA)
- STRCONV (VBA)
- STRREVERSE (VBA)
- SUBSTITUTE (WS)
- T (WS)
- TEXT (WS)
- TEXTJOIN (WS)
- TRIM (WS, VBA)
- UCASE (VBA)
- UNICHAR (WS)
- UNICODE (WS)
- UPPER (WS)
- VAL (VBA)
- VALUE (WS)

Date/Time Functions
- DATE (WS)
- DATE (VBA)
- DATEADD (VBA)
- DATEDIF (WS)
- DATEDIFF (VBA)
- DATEPART (VBA)
- DATESERIAL (VBA)
- DATEVALUE (WS, VBA)
- DAY (WS, VBA)
- DAYS (WS)
- DAYS360 (WS)
- EDATE (WS)
- EOMONTH (WS)
- FORMAT DATES (VBA)
- HOUR (WS, VBA)
- ISOWEEKNUM (WS)
- MINUTE (WS, VBA)
- MONTH (WS, VBA)
- MONTHNAME (VBA)
- NETWORKDAYS (WS)
- NETWORKDAYS.INTL (WS)
- NOW (WS, VBA)
- SECOND (WS)
- TIME (WS)
- TIMESERIAL (VBA)
- TIMEVALUE (WS, VBA)
- TODAY (WS)
- WEEKDAY (WS, VBA)
- WEEKDAYNAME (VBA)
- WEEKNUM (WS)
- WORKDAY (WS)
- WORKDAY.INTL (WS)
- YEAR (WS, VBA)
- YEARFRAC (WS)

Math/Trig Functions
- ABS (WS, VBA)
- ACOS (WS)
- ACOSH (WS)
- AGGREGATE (WS)
- ASIN (WS)
- ASINH (WS)
- ATAN (WS)
- ATAN2 (WS)
- ATANH (WS)
- ATN (VBA)
- CEILING (WS)
- CEILING.PRECISE (WS)
- COMBIN (WS)
- COMBINA (WS)
- COS (WS, VBA)
- COSH (WS)
- DEGREES (WS)
- EVEN (WS)
- EXP (WS, VBA)
- FACT (WS)
- FIX (VBA)
- FLOOR (WS)
- FORMAT NUMBERS (VBA)
- INT (WS, VBA)
- LN (WS)
- LOG (WS)
- LOG (VBA)
- LOG10 (WS)
- MDETERM (WS)
- MINVERSE (WS)
- MMULT (WS)
- MOD (WS)
- MOD (VBA)
- ODD (WS)
- PI (WS)
- POWER (WS)
- PRODUCT (WS)
- RADIANS (WS)
- RAND (WS)
- RANDBETWEEN (WS)
- RANDOMIZE (VBA)
- RND (VBA)
- ROMAN (WS)
- ROUND (WS)
- ROUND (VBA)
- ROUNDDOWN (WS)
- ROUNDUP (WS)
- SGN (VBA)
- SIGN (WS)
- SIN (WS, VBA)
- SINH (WS)
- SQR (VBA)
- SQRT (WS)
- SUBTOTAL (WS)
- SUM (WS)
- SUMIF (WS)
- SUMIFS (WS)
- SUMPRODUCT (WS)
- SUMSQ (WS)
- SUMX2MY2 (WS)
- SUMX2PY2 (WS)
- SUMXMY2 (WS)
- TAN (WS, VBA)
- TANH (WS)
- TRUNC (WS)

Statistical Functions
- AVEDEV (WS)
- AVERAGE (WS)
- AVERAGEA (WS)
- AVERAGEIF (WS)
- AVERAGEIFS (WS)
- BETA.DIST (WS)
- BETA.INV (WS)
- BETADIST (WS)
- BETAINV (WS)
- BINOM.DIST (WS)
- BINOM.INV (WS)
- BINOMDIST (WS)
- CHIDIST (WS)
- CHIINV (WS)
- CHITEST (WS)
- COUNT (WS)
- COUNTA (WS)
- COUNTBLANK (WS)
- COUNTIF (WS)
- COUNTIFS (WS)
- COVAR (WS)
- FORECAST (WS)
- FREQUENCY (WS)
- GROWTH (WS)
- INTERCEPT (WS)
- LARGE (WS)
- LINEST (WS)
- MAX (WS)
- MAXA (WS)
- MAXIFS (WS)
- MEDIAN (WS)
- MIN (WS)
- MINA (WS)
- MINIFS (WS)
- MODE (WS)
- MODE.MULT (WS)
- MODE.SNGL (WS)
- PERCENTILE (WS)
- PERCENTRANK (WS)
- PERMUT (WS)
- QUARTILE (WS)
- RANK (WS)
- SLOPE (WS)
- SMALL (WS)
- STDEV (WS)
- STDEVA (WS)
- STDEVP (WS)
- STDEVPA (WS)
- VAR (WS)
- VARA (WS)
- VARP (WS)
- VARPA (WS)

Logical Functions
- AND (WS)
- AND (VBA)
- CASE (VBA)
- FALSE (WS)
- FOR...NEXT (VBA)
- IF (WS)
- IF (more than 7) (WS)
- IF (up to 7) (WS)
- IF-THEN-ELSE (VBA)
- IFERROR (WS)
- IFNA (WS)
- IFS (WS)
- NOT (WS)
- OR (WS)
- OR (VBA)
- SWITCH (WS)
- SWITCH (VBA)
- TRUE (WS)
- WHILE...WEND (VBA)

Information Functions
- CELL (WS)
- ENVIRON (VBA)
- ERROR.TYPE (WS)
- INFO (WS)
- ISBLANK (WS)
- ISDATE (VBA)
- ISEMPTY (VBA)
- ISERR (WS)
- ISERROR (WS, VBA)
- ISLOGICAL (WS)
- ISNA (WS)
- ISNONTEXT (WS)
- ISNULL (VBA)
- ISNUMBER (WS)
- ISNUMERIC (VBA)
- ISREF (WS)
- ISTEXT (WS)
- N (WS)
- NA (WS)
- TYPE (WS)

Financial Functions
- ACCRINT (WS)
- ACCRINTM (WS)
- AMORDEGRC (WS)
- AMORLINC (WS)
- DB (WS)
- DDB (WS, VBA)
- FV (WS, VBA)
- IPMT (WS, VBA)
- IRR (WS, VBA)
- ISPMT (WS)
- MIRR (WS, VBA)
- NPER (WS, VBA)
- NPV (WS, VBA)
- PMT (WS, VBA)
- PPMT (WS, VBA)
- PV (WS, VBA)
- RATE (WS, VBA)
- SLN (WS, VBA)
- SYD (WS, VBA)
- VDB (WS)
- XIRR (WS)

Database Functions
- DAVERAGE (WS)
- DCOUNT (WS)
- DCOUNTA (WS)
- DGET (WS)
- DMAX (WS)
- DMIN (WS)
- DPRODUCT (WS)
- DSTDEV (WS)
- DSTDEVP (WS)
- DSUM (WS)
- DVAR (WS)
- DVARP (WS)

Engineering Functions
- BIN2DEC (WS)
- BIN2HEX (WS)
- BIN2OCT (WS)
- COMPLEX (WS)
- CONVERT (WS)

File/Directory Functions
- CHDIR (VBA)
- CHDRIVE (VBA)
- CURDIR (VBA)
- DIR (VBA)
- FILEDATETIME (VBA)
- FILELEN (VBA)
- GETATTR (VBA)
- MKDIR (VBA)
- SETATTR (VBA)

Data Type Conv. Functions
- CBOOL (VBA)
- CBYTE (VBA)
- CCUR (VBA)
- CDATE (VBA)
- CDBL (VBA)
- CDEC (VBA)
- CINT (VBA)
- CLNG (VBA)
- CSNG (VBA)
- CSTR (VBA)
- CVAR (VBA)
Home | About Us | Contact Us | Testimonials | Donate
While using this site, you agree to have read and accepted our Terms of Service and Privacy Policy.
Copyright © 2003-2025 TechOnTheNet.com. All rights reserved.
Từ khóa » How To Use Vba In Excel
-
VBA - Excel Macros - Tutorialspoint
-
Insert And Run VBA Macros In Excel - Step-by-step Guide
-
Excel VBA Beginner Tutorial - YouTube
-
Getting Started With VBA In Office - Microsoft Docs
-
VBA In Excel: What Is Visual Basic For Applications, How To Use
-
Excel VBA Tutorial - Easy Excel Programming
-
VBA In Excel - Overview, Common Uses In Finance, Shortcuts
-
Excel VBA Tutorial – How To Write Code In A Spreadsheet Using ...
-
VBA Code Examples For Excel
-
Visual Basic Editor - How To Open And Use It In Excel
-
How To Add Macro Code To Excel Workbook - Contextures
-
MS Excel 2016: Open The Visual Basic Editor - TechOnTheNet
-
Excel VBA Tutorial With Real-time VBA Examples | Simplilearn
-
How To Use The VBA Editor In Excel - Spreadsheeto