Results 1 to 3 of 3

Thread: Creating a Personalised Vba Form

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2005
    Posts
    2

    Smile Creating a Personalised Vba Form

    Good afternoon,

    I have only got a very little knowledge of Visual Basic and I Would like to create a full working code for one of the Excel document that I am using.
    I am trying to create a personalised form in which data can be entered. I have 9 different fields and 1 of them works like an “Access” autonumber (incremented by 1).
    I am using the following code to find the last data row or the first empty line:
    iRow = ws.Cells(Rows.Count, 1) _
    .End(xlUp).Offset(1, 0).Row
    I would like the column with the “autonumber data” to be already filled on the worksheet
    . Is there any possibility to change the previous code in order to find the first row with no data and ignoring the first column state ( which would be already filled).


    Thank you,
    Last edited by L'apprentis; Apr 20th, 2005 at 03:14 AM.

  2. #2
    Addicted Member
    Join Date
    Aug 2002
    Location
    Luton, UK
    Posts
    178

    Re: Creating a Personalised Vba Form

    Code:
    ws.Cells(iRow,1).Value=iRow
    or
    Code:
    ws.Cells(iRow,1).Value=ws.Cells(iRow-1,1).Value +1
    Regards
    BrianB
    -------------------------------

  3. #3
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Omaha, NE
    Posts
    270

    Re: Creating a Personalised Vba Form

    Assuming that your "Autonumber" cell is in column A, you could do something like this.
    VB Code:
    1. 'Selects the first empty row
    2. Range("A2").End(xlDown).Offset(1,0).Select
    3. 'Creates the next Autonumber value in this empty row
    4. Activecell.Value = ActiveCell.Offset(-1,0).Value + 1
    Hope this helps.
    Nate

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width