View Full Version : Solved: Inserting Rows after a count
alopecito
04-02-2009, 10:45 AM
Hi I have a spreadsheet with over 700 sales. I need to count one of the columns, if the amount is more than "0", I need to insert one row after that and stop the count...
I want to avoid stopping the codes just to do this manually since I don't know how to do it!
Thanks in advance!!!
AZIQN
04-02-2009, 12:29 PM
Hi alopecito, could you be a bit more specific in your description, or maybe post an example workbook? Thanks.
alopecito
04-02-2009, 12:45 PM
I'm including a sample. I just need a code that insert a row when finds an amount greater than Cero in the column F....and stops.
Thanks:help
AZIQN
04-06-2009, 12:23 PM
Hello again alopecito. Sorry it took so long to respond, I got caught up with other things. Anyway, I think the following code will do what you described. It finds a value greater than zero, inserts a row beneath it, then stops. Let me know if you'd like it to do something else. Thanks.
Sub InsertStop()
Dim LastRow As Long
Dim i As Integer
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 2 To LastRow Step 1
If .Cells(i, "F").Value > 0 Then
i = i + 1
.Rows(i).insert
Exit Sub
End If
Next i
End With
End Sub
alopecito
04-06-2009, 12:41 PM
Thanks!! it works perfectly!
alopecito
04-06-2009, 12:41 PM
Thanks!! it works perfectly!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.