Accurate, so use the basic control structures programming.
have only one problem:
whether we are talking about a few rows, the time spent by each procedure is virtually the same. However if the table in question (for example) 56,000 rows, execution times are changing as many times, because with the loop, vba must iterate to find the 56,000 empty... 9000 or from the bottom up, until you find the first busy. And See, that for each iteration should also assess a condition, thus execution times are doubled.
Code:
Row = Cells (65536, 1). End (xlUp). Row
I say to excel: 65,536 from the row (of column 1), desolve the number of the first row occupied and takes 0.000000000000001 seconds to do so, regardless of the number of records that exist.
VBA provides us with many tools and features that allow us to put aside the classical structures and provide our applications faster.
something else: the fact use the "activate" and "select" much too slow implementation of the macro. we just call them if we need to choose whether or activate the cell.
let's take an example:
I delete a row:
Code:
Range ( "a1"). Select
Selection.EntireRow.Delete
I also delete the row, but using less code:
Code:
Range ( "A1"). EntiereRow.Delete
Does it mean the idea?
is a small input and clarification, go to the applications that perform better.
a trick:
Many times when you run a macro that clears leaves or rows, columns, etc, etc, we can see the screen as "blink" ... this is "fatal", speaking in terms of time, because the PC should send data to the monitor, and so on.
this "flicker" can be avoided with an instruction:
Example:
Code:
Sub BorrarFiles ()
Dim X as Long
'I am here to refresh the screen is terminated:
Application.ScreenUpdating = False
'beginning with the erasure:
For X = 10 to 100
Cells (X, 1). EntireRow.Delete
Next X
'and always turn back to what disabled:
Application.ScreenUpdating = True
End Sub
Bookmarks