Explain about INSTR Function
Private Sub CommandButton1_Click()
Dim max As Integer
max = Range(Range("A1"), Range("A1").End(xlDown)).Rows.Count
Dim i As Integer
For i = 1 To max
'find "a" postion in specified string
Cells(i, 2) = InStr(Cells(i, 1), "a")
Next
End Sub
Example: Instr Function - - retrieve part of string
Private Sub CommandButton1_Click()
Dim i As Integer
i = 1
Max = Range(Range("A1"), Range("A1").End(xlDown)).Rows.Count
For i = 1 To Max
'through instr function we find the BLANK position
Cells(i, 2).Value = Left(Cells(i, 1), InStr(Cells(i, 1), " ") - 1)
Cells(i, 3).Value = Right(Cells(i, 1), InStr(Cells(i, 1), " "))
Next
End Sub
State about InstrRev Function
Private Sub CommandButton1_Click()
Dim max As Integer
max = Range(Range("A1"), Range("A1").End(xlDown)).Rows.Count
Dim i As Integer
For i = 1 To max
'find "a" postion in specified string
Cells(i, 2) = InStrRev(Cells(i, 1), "a")
Cells(i, 3) = InStr(Cells(i, 1), "a")
Next
End Sub
Len Function
Private Sub CommandButton1_Click()
MsgBox Len("sriguranjani")
Range("B1") = Len(Range("A1"))
End Sub
Rank Function
Private Sub CommandButton1_Click()
Dim I As Integer
Max = Range("B1").End(xlDown).Row
Dim data As Range
Max = Range("B1").End(xlDown).Row
Set data = Sheets("sheet2").Range("B1:B" & Max)
For I = 2 To Max
Cells(I, 3).Value = Application.WorksheetFunction.Rank(Cells(I, 2), data)
Next
End Sub
LCASE Function
Private Sub CommandButton1_Click()
Dim max As Integer
max = Range(Range("A1"), Range("A1").End(xlDown)).Rows.Count
Dim i As Integer
For i = 1 To max
Cells(i, 2) = LCase(Cells(i, 1))
Next
End Sub
LCASE & Ucase Functions
Private Sub CommandButton1_Click()
For Each cell In UsedRange.Cells
cell.Value = UCase(cell.Value)
Next
End Sub
Private Sub CommandButton2_Click()
For Each cell In UsedRange.Cells
cell.Value = LCase(cell.Value)
Next
End Sub
Toogle case
Private Sub CommandButton1_Click()
Dim i As Integer, script
For i = 1 To 16
script = Cells(i, 1).Value
If Mid(script, 1, 1) = LCase(Mid(script, 1, 1)) Then
Cells(i, 1) = UCase(Cells(i, 1))
ElseIf Mid(script, 1, 1) = UCase(Mid(script, 1, 1)) Then
Cells(i, 1) = LCase(Cells(i, 1))
End If
Next
End Sub
Upper Function
Private Sub CommandButton1_Click()
Dim max As Integer
max = Range(Range("A1"), Range("A1").End(xlDown)).Rows.Count
Dim i As Integer
For i = 1 To max
Cells(i, 2) = UCase(Cells(i, 1))
Next
End Sub
Proper Function
Private Sub CommandButton1_Click()
Dim i As Integer
Dim max As Integer
max = Range(Range("A1"), Range("A1").End(xlDown)).Rows.Count
For i = 1 To max
Cells(i, 2) = WorksheetFunction.Proper(Cells(i, 1))
Next
End Sub
Private Sub CommandButton1_Click()
Dim i As Variant
Dim rng As Range
Set rng = Application.InputBox("select_range", Type:=8)
For i = 1 To rng.Cells.Count
rng.Cells(i, 2) = WorksheetFunction.Proper(rng.Cells(i, 1))
Next
End Sub
LEFT Function
Private Sub CommandButton1_Click()
Dim max As Integer
max = Range(Range("A1"), Range("A1").End(xlDown)).Rows.Count
Dim i As Integer
For i = 1 To max
Cells(i, 2) = Left(Cells(i, 1), 3)
Next
End Sub
Explain about RIGHT Function
Private Sub CommandButton1_Click()
Dim max As Integer
max=Range(Range("A1"),Range("A1").End(xlDown)).Rows.Count
Dim i As Integer
For i = 1 To max
Cells(i, 2) = Right(Cells(i, 1), 3)
Next
End Sub
Remove Last Character from Right
Private Sub CommandButton1_Click()
Dim max As Integer
max = Range(Range("A1"), Range("A1").End(xlDown)).Rows.Count
Dim i As Integer
For i = 1 To max
'MsgBox Len(Cells(i, 1)) - 1
Cells(i, 2) = Left(Cells(i, 1), Len(Cells(i, 1)) - 1)
Next
End Sub
Trim Function
Private Sub CommandButton1_Click()
Max = Range("B1").End(xlDown).Row
For i = 1 To Max
Cells(i, 2) = Application.WorksheetFunction.Trim(Cells(i, 2))
Next
End Sub
Trim Function - Selection through INPUTBOX
Private Sub CommandButton1_Click()
Dim max As Range
Dim i As Integer
Set max = Application.InputBox("Select the Range", Type:=8)
For i = 1 To max.Cells.Count
Cells(i, 2) = Application.WorksheetFunction.Trim(Cells(i, 2))
Next
End Sub