Consulting

Results 1 to 5 of 5

Thread: Select data down to next empty cell in column

  1. #1
    VBAX Contributor
    Joined
    Oct 2013
    Posts
    181
    Location

    Select data down to next empty cell in column

    I am using the VBA FIND feature in Excel 2010 (see code below) to locate and select employee numbers from a report generated by another system. After the employee number is selected, need to select down to the next empty cell within the column and everything in between. The information for each employee is different each day, each employee could have 2 lines of information or 15 lines so the code would select the employee number and select down to the first empty cell after the employee number.

    Hope this makes sense and thank you any and all help

    GCell.Select
        If GCell Is Nothing Or GCell = "" Then GoTo Line1
        IsEmpty Range(GCell.End(xlDown).offset(1, 0), GCell.offset(0, 20)).Select
        lr = lastrow(DestSh)
        Selection.Copy Destination:=Sheets("ProductionTotals").Range("C" & lr + 3)
    Line1:
        GCell1.Select
        If GCell1 Is Nothing Or GCell1 = "" Then GoTo Line2
        IsEmpty Range(GCell1.End(xlDown).offset(1, 0), GCell1.offset(0, 20)).Select
        lr = lastrow(DestSh)
        Selection.Copy Destination:=Sheets("ProductionTotals ").Range("C" & lr + 3)
    Line2:
        GCell2.Select
        If GCell2 Is Nothing Or GCell2 = "" Then GoTo Line3
        IsEmpty Range(GCell2.End(xlDown).offset(1, 0), GCell2.offset(0, 20)).Select
        lr = lastrow(DestSh)
        Selection.Copy Destination:=Sheets("ProductionTotals ").Range("C" & lr + 3)

  2. #2
    VBAX Contributor
    Joined
    Oct 2013
    Posts
    181
    Location
    I figured it out. Sorry for asking a question with out thinking it through.

  3. #3
    You only show part of the code but would this not do the same?

    Sub Maybe()
        Range(Selection, Selection.End(xlDown)).Copy Sheets("ProductionTotals ").Range("C" & lr + 3)
    End Sub
    If not, could you be so kind and show your fixed code for people that are searching for a solution to the same or similar problem.

  4. #4
    VBAX Contributor
    Joined
    Oct 2013
    Posts
    181
    Location
    Sorry for any inconvenience for this post!

    jolivanes,

    You are correct the code I posted will and does work for the problem I posted the only problem I had was there was an extra row in between the selection and the next row empty row. In my hast and frustration, I over looked the extra space. When I removed the space the code I submitted worked. Again I apologizes for any inconvenience this my have caused.

  5. #5
    Thank you for updating.

Posting Permissions

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