VBA Functions

InStr Function - Search for Text within Other Text
returns position in text
 
    =FIND(<criteria>, <text to search>)

    =SEARCH(<criteria>, <text to search>)
    
 
    searchFor = "..."
    For Each cell In someRange
        If instr(cell, searchFor) <> 0 Then
            ...
        End If
    Next cell
    
Top

Index

The Evaluate Function
the code below uses the Evaluate function
write 1 to cell C:10
 
    [c10] = 1
    
both lines belwo return the same result
 
    myVar = Evaluate("SUM(D1:D10)")
    myVar = Application.WorksheetFunctionSum(Range(D1:D10)")
    
can use to set range
 
        [D1:D10].Select
    
can use with named range
line below sets cell in range to 23
 
    [<named range>] = 23
    
Top

Index

Sum Function in Excel VBA
ALT + Equals
 
    =SUM(<range>)
    
in VBA
        
    [f2] = Application.WorksheetFunction.Sum(Range(C:C))
            
(C:C) range includes the entire column C
Top

Index

Count Function in VBA
Count function just counts anything which is a number
  
    [f3] = Application.WorksheetFunction.Count(Range(C:C))
    
CountA function counts rows
  
    [f3] = Application.WorksheetFunction.CountA(Range(C:C))
    
  
 
Top

Index

n4jvp.com