Offline Notepad View raw

Shared snapshot

Shared note

Mid(string, start, length) - Returns a substring. Dim subStr As String subStr = Mid("Hello", 2, 3) ' Result: "ell"

Left(string, length) - Returns leftmost characters. Dim leftStr As String leftStr = Left("Hello", 2) ' Result: "He"

Right(string, length) - Returns rightmost characters. Dim rightStr As String rightStr = Right("Hello", 3) ' Result: "llo"

UCase(string) - Converts to uppercase. Dim upperStr As String upperStr = UCase("hello") ' Result: "HELLO"

LCase(string) - Converts to lowercase. Dim lowerStr As String lowerStr = LCase("HELLO") ' Result: "hello"

Trim(string) - Removes leading/trailing spaces. Dim trimmedStr As String trimmedStr = Trim(" Hello ") ' Result: "Hello"

Replace(string, find, replace) - Replaces occurrences. Dim newStr As String newStr = Replace("Hello World", "World", "VBA") ' Result: "Hello VBA"

Sqr(number) - Returns the square root. Dim squareRoot As Double squareRoot = Sqr(16) ' Result: 4

Rnd - Generates a random number between 0 and 1. Dim randomNum As Double randomNum = Rnd ' Random value between 0 and 1

Int(number) - Returns the integer part. Dim intValue As Integer intValue = Int(5.7) ' Result: 5

Date - Returns the current date. Dim currentDate As Date currentDate = Date

Time - Returns the current time. Dim currentTime As Date currentTime = Time

DateAdd(interval, number, date) - Adds time to a date. Dim newDate As Date newDate = DateAdd("d", 5, Now) ' Adds 5 days

Select Case - A more readable way to handle multiple conditions. Select Case dayOfWeek Case 1 MsgBox "Sunday" Case 2 MsgBox "Monday" ' Add additional cases as needed End Select

UBound(array) - Returns the upper bound of an array. Dim upperBound As Integer upperBound = UBound(myArray) ' Result: 2

LBound(array) - Returns the lower bound of an array. Dim lowerBound As Integer lowerBound = LBound(myArray) ' Result: 0

Rows.AutoFit - Automatically adjusts row height. Rows.AutoFit

Range.Font.Size - Changes font size. Range("A1:A10").Font.Size = 12 ' Sets font size to 12

Range.Font.Bold - Makes the font bold. Range("B1:B10").Font.Bold = True

Range.Orientation - Adjusts text orientation. Range("C1").Orientation = 90 ' Rotates text to vertical

Chart.SetSourceData - Sets the data source. chartObj.Chart.SetSourceData Source:=Range("A1:B10")

Chart.ChartType - Changes the chart type. chartObj.Chart.ChartType = xlColumnClustered

Chart.HasTitle - Enables/disables chart title. chartObj.Chart.HasTitle = True chartObj.Chart.ChartTitle.Text = "Sales Data"

Range.Formula - Adds a formula. Range("B1").Formula = "=SUM(A1:A10)"

Range.Value (Array) - Adds multiple values. Dim data As Variant data = Array(1, 2, 3, 4, 5) Range("A1:A5").Value = Application.Transpose(data)

Range.Copy and Range.PasteSpecial - Copies data. Range("A1:A10").Copy Range("B1").PasteSpecial Paste:=xlPasteValues