View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default where is the mistake?

SAhh I never thought of that I simply had the numbers 1 to 10 in 10 rows.

Mike

"Stefi" wrote:

Hi Mike,

I supposed a header in Row 1, if there is none, you are right, of course!

Regards,
Stefi


€˛Mike H€¯ ezt Ć*rta:

Stefi,

Did you not mean to start in Row 1?

Range("B1").Select

Mike

"Stefi" wrote:

I suppose you want something like this:

Dim i As Integer
Range("B2").Select
For i = 2 To 10
If Worksheets("sheet1").Range("B" & ActiveCell.Row).Value < _
Worksheets("sheet1").Range("B" & ActiveCell.Row + 1).Value Then
Rows(ActiveCell.Row + 1).Insert Shift:=xlDown
Range("B" & ActiveCell.Row + 2).Select
End If
Next

Regards,
Stefi

€˛xavi garriga€¯ ezt Ć*rta:

I know my programming level is low and sure the mistake is a begginers
mistake...I want to insert a row if the number in row i+1 is bigger than
number than number in row i.

The code I've written is this:

Private Sub CommandButton1_Click()
Dim i As Integer
For i = 1 To 10
If Worksheets("sheet1").Range("B" & i).Value <
Worksheets("sheet1").Range("B" & i + 1).Value Then
Rows("i:i").Insert Shift:=xlDown
End If
Next
End Sub


I can't find the mistake, can you help me????

Thanks!
--
atrep