Consulting

Results 1 to 5 of 5

Thread: Solved: Search for first open cell in Row

  1. #1
    VBAX Regular
    Joined
    Nov 2006
    Posts
    81
    Location

    Solved: Search for first open cell in Row

    Hi I need to find the first empty cell in a row ...

    I first search with this this code down the column.

    [vba]Sub Search()
    Dim c
    For Each c In Range("C:C").Cells
    If c = "" Then
    c.Select
    Exit For
    End If
    Next
    End Sub
    [/vba]

    So I want to search the ActiveCell row for first empty cell.

    Thank you

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]
    Sub Search
    Cells(1, Activecell.Column).End(xlDown).Offset(1,0).Select
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    If you REALLY mean row, try

    [vba]
    Sub Search
    Cells(Activecell.Row, 1).End(xlDown).Offset(1,0).Select
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    VBAX Regular
    Joined
    Nov 2006
    Posts
    81
    Location
    The last one that searches the row gives a Run-time error 1004...

    Won't that just select the next cell to the Active Cell?

    Lets say that the first cell depending on entries could be in X or A or AB depending on amount of entries. So it should search the whole row until it finds the empty cell.

    I am thinking something like..

    Cells(Activecell.row) search
    If value ="" then
    cell.select

    Could that be right?
    Regards

  5. #5
    VBAX Regular
    Joined
    Nov 2006
    Posts
    81
    Location
    This seems to work
    [VBA]Do While ActiveCell.Offset(0, 1) <> ""
    ActiveCell.Offset(0, 1).Activate
    Loop

    ActiveCell.Offset(0, 0).Value = TextBox2 [/VBA]

    thanks for the help.

Posting Permissions

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