Results 1 to 7 of 7

Thread: Help with VB

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2006
    Posts
    25

    Help with VB

    I am trying to loop the code to find the first empty cell in an already determined column. Then to remember the row number so I can use this row number to paste information into multiple columns of the same row number.

    I can not remember the looping code to get it to work.

    Can anyone help?

    Thanks

  2. #2

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2006
    Posts
    25

    Re: Help with VB

    I am coding in VB in Excel through the sheets and modules

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jul 2006
    Posts
    25

    Re: Help with VB

    My version says 6.3

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jul 2006
    Posts
    25

    Re: Help with VB

    VBA in Excel

  6. #6

  7. #7
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Help with VB

    Here's a function that will give you the row number, I have also included a proc that shows how to call the function.

    VB Code:
    1. Function FirstEmptyRow(ByRef SearchSheet As Worksheet, ByRef SearchCol As Long) As Long
    2. Dim rngCell As Range
    3.  
    4.     Set rngCell = SearchSheet.Cells(1, SearchCol)
    5.     Do While rngCell.Value <> ""
    6.         Set rngCell = rngCell.Offset(1, 0)
    7.     Loop
    8.    
    9.     FirstEmptyRow = rngCell.Row
    10. End Function
    11.  
    12. 'Here's a sample showing the function in action
    13. Sub testempty()
    14. Dim x As Long
    15.    
    16.     For x = 1 To 4
    17.         Debug.Print FirstEmptyRow(ThisWorkbook.Worksheets(1), x)
    18.     Next x
    19. End Sub
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

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