Demonstration script that adds data to four different cells in a spreadsheet, then uses the Range object to format multiple cells at the same time.
Set excel = CreateObject( "Excel.Application" )
With excel
.Visible = True
.Workbooks.Add
.Cells( 1, 1 ).Value = "Name"
.Cells( 1, 1 ).Font.Bold = True
.Cells( 1, 1 ).Interior.ColorIndex = 30
.Cells( 1, 1 ).Font.ColorIndex = 2
.Cells( 2, 1 ).Value = "Test value 1"
.Cells( 3, 1 ).Value = "Test value 2"
.Cells( 4, 1 ).Value = "Tets value 3"
.Cells( 5, 1 ).Value = "Test value 4"
End With
Set range = excel.Range( "A1","A5" )
range.Font.Size = 14
Set range = excel.Range( "A2","A5" )
range.Interior.ColorIndex = 36
Set range = excel.ActiveCell.EntireColumn
range.AutoFit()
Posted in MS-Excel

daniva




Recent Comments