The Cells Object

The Cells Object
Cells is similar to Range
 
    Cells(<row number>,<column number>)
    
suitable for looping
 
    Sub cell()
        Cells(1,2) = 50 ' populates cell with 50
    End Sub
    
Top

Index

Using Column Letters instead of Numbers
 
    Sub cell()
        Cells(1, "B") = 50 ' same result as above
    End Sub      
    
Top

Index

Using Cells Positionally within a Range
the macro below sets the sixth cell (C6) in the range to 44
 
    Sub cells()
        Range("A2:C16".Cells(6) = 44
    End Sub
    
Top

Index

Affecting All Cells in a Worksheet
the macro below changes all the cells in a worksheet
 
    Sub cellsSub()
        cells.Font.Name = "Arial"
        cells.Font.Size = 22
    End Sub
    
Top

Index

Using Range Object with Cells Object
the macro below set the cells in the range B1 to C4 to 44
 
    Sub cellsSub()
        Range(Cells(1,2), Cells(4,3)) = 44
    End Sub
    
Top

Index

Exercise 3
    Sub exercise3()
        Cells.Font.Name = "Arial"
        ActiveWindow.Zoom = 145
        Columns("D:D").Style = "currency"
    End Sub
            
Top

Index

n4jvp.com