+ Reply to Thread
Results 1 to 6 of 6

Error when using IsNumeric

  1. #1
    Registered User
    Join Date
    03-25-2008
    Posts
    31

    Error when using IsNumeric

    Hello,

    I wrote this code to find values greater then 150000 and replace it with the value in the previous cell in column 2 staring at row 2 till the last cell that contains a value.

    I used the IsNumeric command to look in each cell. I ran the code and it changed all the numbers that were above 150000. Then before it finished the error came up. It is a Aplication-Defiend or Object-Defiend error. Does any one have any ideas why this is happening?

    Also is there any way that I can use the IsNumeric command in the While condition line?

    Please Login or Register  to view this content.
    Thank you for your help.
    Last edited by VBA Noob; 11-04-2008 at 03:02 PM. Reason: Added code tags as per forum rules

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Error when using IsNumeric

    Perhaps something like this:

    Please Login or Register  to view this content.
    Is that something you can work with?

    Note: There was some ambiguity in your description. I assumed that you
    intend to start at cell B2 and work DOWN through the column.
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Here's a variation:
    Please Login or Register  to view this content.
    The reason you get an error is that an empty cell returns True for IsNumeric, so you run past the end of the sheet.
    Last edited by shg; 11-04-2008 at 03:05 PM. Reason: correct the error Roy spotted
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    03-25-2008
    Posts
    31
    Thanks for the replys,

    I do have a question though,
    clearly I'm new at this and was wondering about the "with"? I kind of get the idea of what it is doing but would like to read in to it more. I have been looking for a site with all the syntax on it but am having trouble finding one. I checked the msdn site but I could quite seem to find the syntax. I'm guessing it is there and I'm just not naviagting the right way. Do you guys have any suggestions?

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    It's really a kind of short hand, if you use With you don't need to specify it again, So in shgs code see the added comments

    Please Login or Register  to view this content.
    Basically,If you are using several statement that apply to the same object, use a WITH statement, rather than fully qualifying the object each time.
    Last edited by royUK; 11-04-2008 at 01:12 PM.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Registered User
    Join Date
    03-25-2008
    Posts
    31
    Thanks for your help guys, I have it working and understand it. I have another question abouut but I belive it would be benifical in a new Thread.

    Thanks again, you guys are supper fast.

+ 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