Quantcast
Channel: Excel IT Pro Discussions forum
Viewing all articles
Browse latest Browse all 11829

autonumber a row in excel 2010 vba user form

$
0
0

Hello all, I have this code working but not very well.  I have to put a value of 1 in cell A2 then it works  ok (saves the first record as one, next as 2 etc...,  Any ideas on how to populate A2 with an auto number. I need to assign id's for later use.

Private Sub cmdAddProbOpps_Click()
' Save form contents before changing rows:
   SaveRow
' Set current row to first empty row, i.e. one row after
    '  the last row currently in use:
    If Cells(1, 1).Value = "" Then
       lCurrentRow = 2  ' (list is empty - start in row 1)
    Else
       lCurrentRow = ActiveSheet.UsedRange.Rows.Count + 1
    End If
    ' Clear the form for user to add new name:

    txtProbOppTblID.Value = WorksheetFunction.Max(Sheet2.Range("a:a")) + 1
     txtProblemsOpportunitiesTbl.Value = ""
       ' Set focus to Name textbox:
    Me.txtProblemsOpportunitiesTbl.SetFocus
End Sub


Viewing all articles
Browse latest Browse all 11829

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>