View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default macro definition

Forget this response... you are correct.
(10 Mod 2 = 0) - True - True = 1
Now I get it... Just an odd way of doing it...
--
HTH...

Jim Thomlinson


"Jim Thomlinson" wrote:

I believe it subtracts to the previous even row number

iLastRow = iLastRow - (iLastRow Mod 2 = 0)

For example
10-10 Mod 2 = 10
11-11 Mod 2 = 10
--
HTH...

Jim Thomlinson


"Tom Ogilvy" wrote:

it finds the lastrow with data in column "N"

if it is an odd row, it starts there. If it is an even row, it adds 1 to
the row and starts there.

It then steps back to row 2 looking only at the odd rows.

For each odd row, it inserts a new row. It goes from high numbered row to
low numbered row to avoid having the macro adversely affected by changes it
has made.

--
Regards,
Tom Ogilvy


"andresg1975" wrote:

can someone explain to me the function of this macro. Thanks for your help

Sub INSONEEVERYTWOROWS()
Dim iLastRow As Long
Dim i As Long

iLastRow = Cells(Rows.Count, "N").End(xlUp).Row
iLastRow = iLastRow - (iLastRow Mod 2 = 0)
For i = iLastRow To 2 Step -2
Rows(i).Resize(1).Insert
Next i

End Sub