Results 1 to 3 of 3
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Find cell in table (97+)

    I wrote the attached utility code to locate various cells in a table. It works (there is no error-checking), but seems clunky to me. I rarely write FOR loops based on integer counts.
    The client wants a data base of text and images, stored in a Word table. Given a product id as a key, I am to locate various text and images in the columns that correspond to that key.
    I figured that a generalised table-lookup utility procedure should be able to return the range of any cell given
    (1) the identifier of the column which contained the product id
    (2) the value of the product id key for this call
    (3) the identifier of the column which contained the item being referenced.

    To see it work, drag and de-comment the self-testing procedure out of the procedure and run it. The macro should highlight the time of the postal collection postal pick up at Saturn plaza on a Saturday (11:05 a.m.)

    Comments and suggestions welcomed .....
    Attached Files Attached Files

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Find cell in table (97+)

    You could use the Find method instead of looping. And I think you should check at the end of each loop whether the item has been found: if the loop index is 1 more than the upper bound, the item hasn't been found.

    (I would prefer to use Excel or Access for an application like this.)

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Find cell in table (97+)

    Hans, thanks for the nudge.

    >You could use the Find method instead of looping
    True. For some reason that solution had eluded me.
    Since this is a product-identifier lookup, I need the match to be on an entire cell. I think that that is what focussed me on a cell-by-cell approach (hence looping by row and column number). Using Range.Find would leave me holding the found string and then checking to see if the found text was a complete cell.
    Still probably faster than looping, given the uniqueness of product identifiers.

    >check at the end of each loop
    I quite agree; this was skeletal code to support a proof-of-concept model.

    >I would prefer to use Excel or Access for an application like this
    Me too, but client is migrating from a Corel Word Perfect operation and wants to keep the solution in the realms of Word processing.

Posting Permissions

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