Inicio » VBA-Ejemplos » Formatos Excel y VBA

Formatos Excel y VBA

Excel pone a disposición un montón de formatos. Abajo presentamos como modificar algunos de ellos a través de macros Excel VBA.

Redondear celdas

Set Area = Selection
For Each Cell In Area
  z = Round(Cell, 2)
    Cell.Value = z
  Cell.NumberFormat = "#,##0.00"
Next Cell

Formatear fuente

Cells.Select
With Selection.Font
  .Name = "MS Sans Serif"
  .Size = 10
End With

Líneas de división

ActiveWindow.DisplayGridlines = False

Indice de colores

ActiveWorkbook.Colors(44) = RGB(236, 235, 194) 'verde

Colorear rango

Range("A1:B10").Interior.ColorIndex = 44

Cambiar entre estilos A1 / RC

Application.ReferenceStyle = xlA1Application.ReferenceStyle = xlR1C1