Código vb:
Ver original
Dim I As Long, j As Long Dim objExcel As Object Dim objWorkbook As Object On Error Resume Next ' por si se cierra Excel antes de cargar los datos Set objExcel = CreateObject("Excel.Application") objExcel.Visible = False Set objWorkbook = objExcel.Workbooks.Add For I = 0 To grilla.Rows - 1 grilla.Row = I For j = 0 To grilla.Cols - 2 grilla.Col = j If I = 0 Then objWorkbook.ActiveSheet.Cells(I + 1, j + 1).Interior.Color = &H80C0FF objWorkbook.ActiveSheet.Cells(I + 1, j + 1).Font.Bold = True objWorkbook.ActiveSheet.Cells(I + 1, j + 1).Value = grilla.text Else objWorkbook.ActiveSheet.Cells(I + 1, j + 1).Style = "Comma" objWorkbook.ActiveSheet.Cells(I + 1, j + 1).NumberFormat = "_-* #,##0.0_-;-* #,##0.0_-;_-* ""-""??_-;_-@_-" objWorkbook.ActiveSheet.Cells(I + 1, j + 1).NumberFormat = "_-* #,##0_-;-* #,##0_-;_-* ""-""??_-;_-@_-" objWorkbook.ActiveSheet.Cells(I + 1, j + 1).NumberFormat = "_-* #,##0_-" objWorkbook.ActiveSheet.Cells(I + 1, j + 1).Interior.Color = &HC0FFFF objWorkbook.ActiveSheet.Cells(I + 1, j + 1).Value = grilla.text objWorkbook.ActiveSheet.Cells(I + 1, j + 1).HorizontalAlignment = xlRight End If Next objWorkbook.ActiveSheet.Cells(I + 1, 1).NumberFormat = "_-* dd/mm/yyyy_-" Next objExcel.Cells.Select objExcel.selection.EntireColumn.AutoFit ' Ancho de columna objWorkbook.ActiveSheet.Range("A1:h59").Borders().LineStyle = 1 objWorkbook.ActiveSheet.Range("A59:i59").Font.Bold = True objExcel.Range("b1").Select objExcel.Visible = True objExcel.ActiveWindow.SelectedSheets.PrintPreview ' Previsualizar informe Set objWorkbook = Nothing Set objExcel = Nothing
y quiero alinear a la derecha las ultimas 3 columnas y la primera
Como lo puedo hacer ? gracias