IF FUNCTION

  • Thread starter Thread starter Guest
  • Start date Start date
do this experiment
fill a1 to a10 with values some more than 5 some less than 5
and use this vba (perhaps rather pedestrian)
and see whether you get what you want.
this applied whatever be the range of cells.
only condiiton the first row is row no. 1(see statement i=1)
this will work on the active sheet.

Public Sub test()
Dim i As Integer
i = 1

line1:
If Cells(i, 1) > 5 Then
Rows(i).Select
Selection.Insert Shift:=xlDown
i = i + 2
GoTo line1
Else
i = i + 1
If Cells(i, 1) = "" Then GoTo line2
GoTo line1
End If
line2:
Range("a1").Select
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

Back
Top