Results 1 to 4 of 4

Thread: vb6 + Excel

  1. #1
    Join Date
    Dec 2007
    Posts
    1

    Talking Unanswered: vb6 + Excel

    I need to find the first empty cell in excel worksheet programatically.

    Any help would be great

    M

  2. #2
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    Quote Originally Posted by Michael_Whit
    I need to find the first empty cell in excel worksheet programatically.

    Any help would be great

    M
    By row, or by column?

    Also, are you discussing using VB, or VBA?
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


  3. #3
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    Lightbulb Re

    'Code verry quick and verry dirty

    Dim iRow as Int
    Dim iCol as int 'must be an emty cell in here
    FoundEmty as boolean = false
    irow =0
    icol =0

    do until icol = 1000 or FoundEmty=true

    do until irow =1000 or FoundEmty=true

    if me.workbook.cell( icol , irow ). text="" then FoundEmty = true


    irow =irow +1

    loop
    icol =icol +1
    loop


    if FoundEmty then
    msgbox(" Empty cell found row = " & irow " Column = " & icol)
    else
    msgbox(" NO Empty cell found " )
    end if

  4. #4
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    Depending upon the structure of the spreadsheet, it may be much faster to use ADO to connect to the worksheet, and retrieve a recordset containing the spreadsheet contents.

    ref THIS thread at our VB sister site.
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


Posting Permissions

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