+ Reply to Thread
Results 1 to 6 of 6

Problem defining -some- variables in an IF statement

  1. #1
    Registered User
    Join Date
    09-03-2007
    Posts
    51

    Problem defining -some- variables in an IF statement

    The code below loops through a range of people's names in the source spreadsheet and for each one loops through fifty two columns looking for any mention of the current name. Once it finds an occurrence it adds a number (below the name) to any previously found numbers for the same fund type inside the fund's array.
    Finally it writes the total from each fund array to the person's column in a statistics register, zeros the array and then begins again looking for the next person. Eventually the loops complete and the register is saved and closed.
    The issue is that the Fund and Results variables are not set as can be shown with a messagebox immediately following the IF statement in question.

    Please Login or Register  to view this content.
    I would very much appreciate any time anyone can spend helping me get this script to define these variables. Cheers,

    - Gordon

  2. #2
    Forum Contributor
    Join Date
    07-05-2007
    Location
    Lexington, MA
    Posts
    302
    I have put a few suggestions into your subroutine below. New lines are preceeded by "=>" which you will need to remove.
    Please Login or Register  to view this content.
    FrankBoston is the pen name for Andrew Garland, Lexington MA

  3. #3
    Registered User
    Join Date
    09-03-2007
    Posts
    51

    Cool Thank You!

    Thank you VERY much FrankBoston! I didn't think anyone would be up to going through and weeding out my problems in all that code, but you've made about three days of headache evaporate in a blink of an eye!

    Thanks again,

    - Gordon

    LOVE this forum!

  4. #4
    Registered User
    Join Date
    09-03-2007
    Posts
    51

    Unable to stick a cell location into a variable

    PersonCol = Cells.Find(What:=PersonName, LookIn:=xlFormulas, SearchOrder:=xlByColumns).Column
    PersonRow = Cells.Find(What:=Date, LookIn:=xlFormulas, SearchOrder:=xlByRows).Row

    These lines now generate the error "Run-time error '91': Object variable or With block variable not set" and I cannot come up with another way to determine the row and column numbers of the cells found.
    Can anyone see what's wrong there or know another way to get the row/column number of the cells found?

    Thanks for thinking,

    - Gordon

  5. #5
    Forum Contributor
    Join Date
    07-05-2007
    Location
    Lexington, MA
    Posts
    302
    I think one of the Find's is failing, so there is no "object" (the found cell) to provide the .column or .row.

  6. #6
    Registered User
    Join Date
    09-03-2007
    Posts
    51
    Quote Originally Posted by FrankBoston
    I think one of the Find's is failing, so there is no "object" (the found cell) to provide the .column or .row.
    Thanks again FrankBoston, after trapping and correcting the error it works perfectly!

    - Gordon

    LOVE this forum!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1