Print
Category: IT
Hits: 658

Select Range:

http://support.microsoft.com/kb/291308

Find value in range:

    Range("A1:M1").Select
    Set found_cell = Selection.Find(What:="Symbol", After:=ActiveCell, LookIn:=xlValues, _
        LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=True, SearchFormat:=False)
   
    Set comment_cell = Range("A5")
   
    comment_cell.Value2 = found_cell.Column

Loop through rows and change color when value changes

    lastrow = Range("A65536").End(xlUp).Row
    rowcolor = 34    
    For rowLoop = 2 To lastrow
        If Cells(rowLoop, "A") <> Cells(rowLoop - 1, "A") Then
            If (rowcolor = 34) Then
                rowcolor = xlNone
            Else
                rowcolor = 34
            End If
        End If

        Rows(rowLoop).Interior.ColorIndex = rowcolor

    Next rowLoop

 

Create user function that can be called from a cell

Function getSomething

  getSomething = "something"

End Function

Perform a look up from a function

Application.CountIf(Worksheets("TotalTrades").Columns(book_column), trader)

where book_column is an column index

 

Get prior weekday

=TEXT(TODAY() - MAX(WEEKDAY((TODAY()),11)-4,1),"yyyymmdd")