VBA Tips
Date and time
- Calculate the number of days in a month (or the last day of the month)
- Calculate the weekday (1 to 7) or display it in text format (Monday-Sunday, MO-SU)
- Date and time display formats
- Schedule the execution of a macro in X seconds or at a specific time with OnTime
Formatting and text
- Check if a string contains a value (and return its position)
- Convert to uppercase or lowercase (and check if a value is in uppercase or lowercase)
- Format characters in a cell
- Remove unnecessary spaces
- Replace values with others within a string (or remove them)
- Retrieve the color of a cell considering the applied conditional formatting
- Reverse a string
Generators and calculations
- Convert a hexadecimal color to a Color value
- Generate random codes
- Generate random numbers
- Square root (and square)
UserForm and controls
- Create a progress bar
- Create a search field with result display in a ListBox
- Using a variable in a control name
Variables and arrays
- Reset or erase an array
- Search for the position of a value in an array
- Search for the presence of a value in an array
- Sort an array
Various
- Disable events
- Enable (and unblock) Excel macros
- Perform an action depending on Excel’s version
- Simplify conditions in VBA
- Stop a running macro
- Ternary operator
- Using ScreenUpdating to speed up the execution of a macro
- VBA code protection (obfuscator)
Worksheets and Workbooks
- Ban the selection of multiple cells
- Determining the number of the last row
- Display or hide a worksheet
- Force enabling of macros
- Hide tabs
- Prevent editing the name of a tab
- Preventing a file from being saved
- Protect access to VBA code with a password
- Retrieve conditional formatting color with an Excel function