+ Reply to Thread
Results 1 to 2 of 2

Find first empty row in a specific range

  1. #1
    Registered User
    Join Date
    09-23-2010
    Location
    Puerto Rico
    MS-Off Ver
    Excel 2003
    Posts
    1

    Find first empty row in a specific range

    Hi guys,

    I have this code to use with a form and add lines in range A12:J25 Sheet1, problem is that it is giving me an error in the section highlighted in red. The problem is that I need the information from the form to be populated in rows 12 thru 25, each time I add data, it needs to find the first empty row beetween 11 and 25 and place the data there without over writing the prior data. Can anyone help me?


    Private Sub cmdAdd_Click()
    Dim iRow As Long
    Dim ws As Range
    Set ws = Range("A12")

    'find first empty row in database
    iRow = ws.Cells(Rows.Count, 1) _
    .End(xlUp).Offset(1, 0).Row


    'copy the data to the database
    ws.Cells(iRow, 1).Value = Me.ComboBox1.Value
    ws.Cells(iRow, 2).Value = Me.ComboBox2.Value
    ws.Cells(iRow, 6).Value = Me.TextBox3.Value
    ws.Cells(iRow, 7).Value = Me.TextBox1.Value
    ws.Cells(iRow, 8).Value = Me.TextBox2.Value

    'clear the data
    Me.ComboBox1.Value = ""
    Me.ComboBox2.Value = ""
    Me.TextBox3.Value = ""
    Me.TextBox1.Value = ""
    Me.TextBox2.Value = ""
    Me.ComboBox2.SetFocus
    End Sub

  2. #2
    Registered User
    Join Date
    09-18-2010
    Location
    Kalamazoo, MI
    MS-Off Ver
    Excel 2007
    Posts
    37

    Re: Find first empty row in a specific range

    I've used something like this in macros before:

    Dim LastRow as Long

    LastRow = Range("A65536").End(xlUp).Offset(1, 0)

    Hope that helped!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1