Insert Row when zero or Positive value

  • Thread starter FIRSTROUNDKO via OfficeKB.com
  • Start date
F

FIRSTROUNDKO via OfficeKB.com

Hi,

I have sorted a collumn in ascending value from negative to positive, I want
to insert a row when the change in the value is zero or greater. i.e

-2
-1
0
1

Becomes

-2
-1

0
1

The Collumn changes in length and sometimes there maybe no negative numbers
and sometimes there may be no positve numbers

Can sombody Please help me Thanks in advance

Darren
 
T

Tom Ogilvy

assume column 3 (C)

Sub AddRow()
Dim col as Long, i as long
Dim lastrow as Long
col = 3
lastrow=cells(rows.count,col).End(xlup).row
for i = lastrow to 2 step -1
if cells(i-1,col) < 0 then
rows(i).Insert
exit sub
end if
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top