+ Reply to Thread
Results 1 to 6 of 6

Code ceased to function

  1. #1
    Registered User
    Join Date
    01-25-2010
    Location
    Bristol, England
    MS-Off Ver
    Excel 2003
    Posts
    19

    Code ceased to function

    I have been using this code;

    Please Login or Register  to view this content.
    To populate a column based on the first two letters of a reference which appears in another column. For some reason, without any alteration since the last time I used it last week, the code has now stopped working. It does not return any error messages, nor does it hang. The macro runs through the code and simply does nothing to the spreadsheet.

    Anything you can suggest is much appreciated,
    Mar
    Last edited by maruchi; 02-09-2010 at 11:31 AM.

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Code ceased to function

    Hi,

    Can't see anything immediately obvious.

    Can you attach a sample workbook with the code in it.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    01-25-2010
    Location
    Bristol, England
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Code ceased to function

    Here you go.

    I have had to remove some of the information from the preceding columns and have cut it down to just the code that is not working/being skipped.

    Like I said, it worked brilliantly before (thanks to another individual on this forum).

    The macro just skips owner assignment and goes straight into the little bit of formatting I get it to do to prepare for printing.

    Bothersome...
    Mar
    Attached Files Attached Files

  4. #4
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Code ceased to function

    Try changing this:

    Please Login or Register  to view this content.
    to this:

    Please Login or Register  to view this content.

    All intLastRow was doing in your original code was returning 1 so the code was only looking at row 1 and then stopping.

    Dom
    Last edited by Domski; 02-09-2010 at 11:22 AM.

  5. #5
    Registered User
    Join Date
    01-25-2010
    Location
    Bristol, England
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Code ceased to function

    Cheers Dom, that works in mine now too.

    Any idea why it would have worked before?

    Interestingly, while messing about with it myself, I found that placing some value (1, a, cheese) in the last cell in the required column range made the code work!?

    Sometimes Excel is a fickle mistress...

    Thanks again
    Mar

  6. #6
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Code ceased to function

    When checking for the last used row in a sheet it is best to use a column that contains data. Whilst what you had may have produced results before (due to the usedrange of the worksheet being set in that column I think) it will not work consistently hence the problem you faced.

    The code I posted basically tells it to look up row J from the bottom of the column and return the first populated row that it finds. There are other methods but this seems to work well for me.

    Dom

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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