Hi, I couldnt find in the internet a loop that returns a multiple selection.
Private X0, Y0, Lx, Ly, Atotal As Integer
'X0 = Position of the first cell in the first machine on Monday
'X0 = Position of the first cell in the first machine on Monday
'Lx = Widht, in cells, of one day
'Ly = Widht, in cells, of a machine (Anlage)
'Atotal = Total number of "Anlagen"
I am trying that, because I noticed that a macro runs faster if it is executed on a manual multiple range, like:
Sub Spalte()
Range("D:D,N:N,X:X,AH:AH,AR:AR,BB:BB,BL:BL").ColumnWidth = Range("$B$3")
Rows("4:167").EntireRow.AutoFit
End Sub
...faster than a automatic range produced by a loop:
Sub SpalteLoop()
Dim t As Integer
For t = 1 To 7
cells(Y0, X0 + Lx * (t - 1)).ColumnWidth = Range("$B$3")
Next t
Rows("4:167").EntireRow.AutoFit
With ActiveSheet
End Sub
Thus, Im trying to find a way that makes the loop returns a multiple selection, so I can execute the macro on this selection, which would be faster. I noticed that the .Select loop runs faster than the .ClearContents loop. I also using the same automation to clear contents, and it was also faster when it was manual.
-> Makes sense I try to make a loop that returns a multiple selection? How can I do that?
P.S.: I Created the autofit part because I wasnt able to make the cells that contains formulas autofit. My Excel just dont respect it for cells that contains formulas. If it was exectued in every change in the sheet, it would make the workbook slow.
Thanks for the attention!
Private X0, Y0, Lx, Ly, Atotal As Integer
'X0 = Position of the first cell in the first machine on Monday
'X0 = Position of the first cell in the first machine on Monday
'Lx = Widht, in cells, of one day
'Ly = Widht, in cells, of a machine (Anlage)
'Atotal = Total number of "Anlagen"
I am trying that, because I noticed that a macro runs faster if it is executed on a manual multiple range, like:
Sub Spalte()
Range("D:D,N:N,X:X,AH:AH,AR:AR,BB:BB,BL:BL").ColumnWidth = Range("$B$3")
Rows("4:167").EntireRow.AutoFit
End Sub
...faster than a automatic range produced by a loop:
Sub SpalteLoop()
Dim t As Integer
For t = 1 To 7
cells(Y0, X0 + Lx * (t - 1)).ColumnWidth = Range("$B$3")
Next t
Rows("4:167").EntireRow.AutoFit
With ActiveSheet
End Sub
Thus, Im trying to find a way that makes the loop returns a multiple selection, so I can execute the macro on this selection, which would be faster. I noticed that the .Select loop runs faster than the .ClearContents loop. I also using the same automation to clear contents, and it was also faster when it was manual.
-> Makes sense I try to make a loop that returns a multiple selection? How can I do that?
P.S.: I Created the autofit part because I wasnt able to make the cells that contains formulas autofit. My Excel just dont respect it for cells that contains formulas. If it was exectued in every change in the sheet, it would make the workbook slow.
Thanks for the attention!