View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sam Kuo[_3_] Sam Kuo[_3_] is offline
external usenet poster
 
Posts: 86
Default How to get row number?

I use the "Do Until...Loop" in forms subroutine to insert a row in worksheet
at specified location. How do I get the row number of the new row?


Private Sub cmdInsertRow_Click()

Dim ws As Worksheet
Dim a As Long
Set ws = Worksheets("Sheet1")

a = 22 'data starts at row 22
Do Until Trim(ws.Cells(a, 1)) = ""
If ws.Cells(a, 1) = Me.cboRefValue.Value Then
ws.Cells(a + 1, 1).EntireRow.Insert
a = a + 2
Else
a = a + 1
End If
Loop

End Sub