Skip to content
- Excel VBA: Check Whether a Cell Contains TextTo check whether a cell contains a particular string in Excel VBA, use InStr and test whether its result is greater than…VBA & macros
- Excel VBA If Not IsDate: Check Dates in Excel CellsIn Excel VBA, use If Not IsDate(value) Then to run code when a value is not recognized as a date or time.…VBA & macros
- Excel VBA If String Equals: Exact and Case-InsensitiveIn Excel VBA, test whether two strings are equal with If firstText = secondText Then. That comparison is case-sensitive by default; use…VBA & macros
- Excel VBA: Check Whether an Array Contains a ValueTo check whether a VBA array contains a value, loop through its elements and compare each one with the value you are…VBA & macros
- Excel VBA Hyperlink to Worksheet: A Practical GuideTo make a cell link to another worksheet with VBA, use Hyperlinks.Add and set Address to an empty string and SubAddress to…VBA & macros
- Excel VBA: Highlight Cells in an Array LoopTo highlight worksheet cells while looping through an array in Excel VBA, read a range into an array, test each array value,…VBA & macros
- Excel VBA: Hide a Worksheet and Control VisibilityTo hide a worksheet with VBA, set its Visible property to xlSheetHidden: ThisWorkbook.Worksheets("Sheet1").Visible = xlSheetHidden. To keep it out of Excel’s normal…VBA & macros
- Excel VBA Hyperlink: Add, Edit, and TroubleshootExcel VBA does not have a built-in Hyperlink() function: to create a clickable link in a macro, use the Hyperlinks.Add method. For…VBA & macros
- Excel VBA: Hide a Range of Cells or RowsIn Excel VBA, you can hide the entire rows or columns that contain a range, but you cannot hide just an arbitrary…VBA & macros
- Excel VBA: How to Hide a Workbook WindowTo hide the active workbook window with VBA, set its Visible property to False, for example: ThisWorkbook.Windows(1).Visible = False. This hides the…VBA & macros
- Excel VBA: Hide a Column RangeTo hide a range of columns with Excel VBA, set its Hidden property to True: use Columns("B:D").Hidden = True to hide columns…VBA & macros
- Excel VBA: Hide a Column Based on a Cell ValueYes. In Excel for Microsoft 365 on Windows, VBA can set a column’s Hidden property according to the value in a cell.…VBA & macros
- Excel VBA Hex String: Convert Numbers to HexadecimalIn Excel VBA, use the Hex function to turn a number into a hexadecimal string: Hex(255) returns FF. The result has no…VBA & macros
- Excel VBA Hidden Worksheets: Hide and Unhide SheetsIn Excel VBA, hide a worksheet by setting its Visible property to xlSheetHidden or xlSheetVeryHidden; set it to xlSheetVisible to show it…VBA & macros
- Excel VBA Hex Function: Convert Numbers to HexIn Excel VBA, Hex(number) converts a numeric value to a hexadecimal text string: for example, Hex(255) returns FF. It does not add…VBA & macros
- Excel VBA Hard-Coded Arrays: Syntax, Types, and ExamplesYes. In Excel VBA, you can hard-code a list of values with the Array function and assign it to a Variant, such…VBA & macros
- Excel VBA GoTo: How Labels and Errors WorkIn Excel VBA, GoTo is a statement—not a function—that transfers execution to a labeled line in the same procedure. It is also…VBA & macros
- Excel VBA Global Functions: Scope and How to Create OneIn Excel VBA, a global function is usually a Public Function declared in a standard module, making it callable from other modules…VBA & macros
- Excel VBA Global Array Example: Scope, Setup, and UseIn Excel VBA, declare a shared array with a Public statement at the top of a standard module, outside any procedure. For…VBA & macros
- Excel VBA Get Year From Date: Code, Dates, and ErrorsTo get the year from a date in Excel VBA, use the built-in Year function: Year(dateValue). For example, Year(Worksheets("Sheet1").Range("A2").Value) returns the year…VBA & macros
- Excel VBA Get Worksheet by Name: Examples and ErrorsIn Excel VBA, get a worksheet by name with Set ws = ThisWorkbook.Worksheets("Summary"), replacing Summary with the tab name. Use ThisWorkbook when…VBA & macros
- Excel VBA Get Workbook Name: Methods and ExamplesIn Excel VBA, use ThisWorkbook.Name to get the name of the workbook that contains the running code, or ActiveWorkbook.Name to get the…VBA & macros
- Excel VBA Get Worksheet Index: Methods and ExamplesIn Excel VBA, read a worksheet’s Index property to get its position in the workbook’s sheet-tab order: for example, ThisWorkbook.Worksheets("Data").Index. The number…VBA & macros
- Excel VBA: Get a Value From a UserForm TextBoxIn Excel VBA, read a UserForm TextBox with its Value property: for example, userName = Me.txtName.Value inside the form, or userName =…VBA & macros
- Excel VBA: Get a String from a Cell, Safely and ReliablyTo get a cell’s value as a VBA string, read it into a Variant and convert it with CStr: use Value2 for…VBA & macros
- Excel VBA: Get a PivotTable NameIn Excel VBA, get a PivotTable’s name from its Name property: pt.Name. First obtain the PivotTable object from a worksheet’s PivotTables collection,…VBA & macros
- Excel VBA: Get a Named Range’s ValueTo read a workbook-level named range in Excel VBA, get its Range object and read its Value or Value2 property: Set target…VBA & macros
- Excel VBA Get Month From Date: Code, Formats, and TipsIn Excel VBA, use the built-in Month function to get the month number from a date: Month(dateValue) returns a number from 1…VBA & macros
- Excel VBA: Get a PivotTable’s LocationTo get a PivotTable’s location in Excel VBA, use its TableRange2 property and read the range’s address. For example, pt.TableRange2.Address(External:=True) returns the…VBA & macros
- Excel VBA: Get the First Item in a DictionaryTo get the first key from a VBA Scripting.Dictionary, copy its keys into a Variant array and read the first array element:…VBA & macros