Wątek przeniesiony 2024-06-25 13:59 z Inne języki programowania przez cerrato.

Vba optymalizacja kodu.

0

Pytanie co bardziej wydajne i szybsze (1 czy 2) lub możne jest jakiś inny sposób.

Range(Cells(1,1), Cells(1, 2).Select  
    With Selection
        .MergeCells = True 
        .ColumnWidth = 18
        .Font.Size = 8
    End With
    ActiveCell.FormulaR1C1 = "ble ble"
Range(Cells(1,1), Cells(1, 2).MergeCells = True
Range(Cells(1,1), Cells(1, 2).ColumnWidth = 18
Range(Cells(1,1), Cells(1, 2).Font.Size = 8
Range(Cells(1,1), Cells(1, 2).Value = "ble ble"
0
Dim t As Single
t = Timer
'twój kod
MsgBox Timer - t
0

lepiej używać with. Najszybszym rozwiązaniem będzie:

With Range(Cells(1,1), Cells(1,2))
    .MergeCells = True: .ColumnWidth = 18: .Font.Size = 8
    .Value = "ble ble"
End With

jeśli musisz użyć danego obiektu parę razy lepiej użyć with

1 użytkowników online, w tym zalogowanych: 0, gości: 1