ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Vba code meaning (https://www.excelbanter.com/excel-programming/377629-vba-code-meaning.html)

andresg1975

Vba code meaning
 
Can someone tell me what is the meaning if this code

LastRow = Range("A65536").End(xlUp).Row
For i = LastRow To 2 Step -1
If Range("A" & i).Value < _
Range("A" & i - 1).Value Then
Range("A" & i).EntireRow.Insert
End If


thanks a lot








Ron Coderre

Vba code meaning
 
That code

'Record the last row number where the Col_A value is not blank
LastRow = Range("A65536").End(xlUp).Row

Loop backwards up the rows, starting with that row, decrementing by 1
For i = LastRow To 2 Step -1

'If the value of the referenced cell in Col_A does not match the cell
above it...
If Range("A" & i).Value < _
Range("A" & i - 1).Value Then

'Insert a row
Range("A" & i).EntireRow.Insert
End If

'Assuming this code is in there somewhere
Next i

Does that help?
***********
Regards,
Ron

XL2002, WinXP


"andresg1975" wrote:

Can someone tell me what is the meaning if this code

LastRow = Range("A65536").End(xlUp).Row
For i = LastRow To 2 Step -1
If Range("A" & i).Value < _
Range("A" & i - 1).Value Then
Range("A" & i).EntireRow.Insert
End If


thanks a lot








andresg1975

Vba code meaning
 
Yes. I appreciate your help, thanks a lot

"Ron Coderre" wrote:

That code

'Record the last row number where the Col_A value is not blank
LastRow = Range("A65536").End(xlUp).Row

Loop backwards up the rows, starting with that row, decrementing by 1
For i = LastRow To 2 Step -1

'If the value of the referenced cell in Col_A does not match the cell
above it...
If Range("A" & i).Value < _
Range("A" & i - 1).Value Then

'Insert a row
Range("A" & i).EntireRow.Insert
End If

'Assuming this code is in there somewhere
Next i

Does that help?
***********
Regards,
Ron

XL2002, WinXP


"andresg1975" wrote:

Can someone tell me what is the meaning if this code

LastRow = Range("A65536").End(xlUp).Row
For i = LastRow To 2 Step -1
If Range("A" & i).Value < _
Range("A" & i - 1).Value Then
Range("A" & i).EntireRow.Insert
End If


thanks a lot









All times are GMT +1. The time now is 06:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com