+ Reply to Thread
Results 1 to 16 of 16

If foundrane is nothing then resume

Hybrid View

  1. #1
    Registered User
    Join Date
    06-25-2009
    Location
    Houston, TX
    MS-Off Ver
    Excel 2003
    Posts
    13

    If foundrane is nothing then resume

    Hey all,

    I'm trying to have a macro move down one cell and resume from the start if it finds nothing, but I'm running into problems....

    Cells.Find(What:=Range("A1"), after:=ActiveCell).Activate
        If FoundRange Is Nothing Then
            Sheets("Data").Select
            ActiveCell.Offset(1, 0).Select
            Run (Macro)
        
        Else
           
        End If
    Thanks!

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: If foundrane is nothing then resume

    Hello giantfan87,

    What is the problem you are having?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    06-25-2009
    Location
    Houston, TX
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: If foundrane is nothing then resume

    It's giving me a runtime error and highlighting the "If foundrange is nothing then" line.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: If foundrane is nothing then resume

    Hello giantfan87,

    Your code snippet does not show if you are assigning the variable FoundRange to the Cells.Find statement. This would cause the error. You code should like similar to this...
    Dim FoundRange As Range
    
      Set FoundRange = Cells.Find(What:=Range("A1"), after:=ActiveCell).Activate
         If FoundRange Is Nothing Then
            Sheets("Data").Select
            ActiveCell.Offset(1, 0).Select
            Run (Macro)
         Else
           
        End If

  5. #5
    Registered User
    Join Date
    06-25-2009
    Location
    Houston, TX
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: If foundrane is nothing then resume

    It's still giving me an error, says I need to define an object.

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: If foundrane is nothing then resume

    Hello giantfan87,

    You should post your workbook for review.

  7. #7
    Registered User
    Join Date
    06-25-2009
    Location
    Houston, TX
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: If foundrane is nothing then resume

    Figured out how to label a line. Problem still persists as follows: I want it to diplay a message saying "works" if something is found. If nothing is found I want it to offset 1 row and go to line "nada". The way it is written it seems to be ignoring the activecell.offset lines.

    Nada: Selection.Copy
    Sheets("TYP Strips").Select
    Range("A1").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    
    Dim foundrange As Range
    Set foundrange = Cells.Find(What:=Range("A1"), after:=ActiveCell)
        Cells.Find(What:=Range("A1"), after:=ActiveCell).Activate
        If foundrange Is Nothing Then
        Sheets("Data").Select
        ActiveCell.Offset(1, 0).Select
        GoTo Nada
        
        Else
           MsgBox ("works")
        End If

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: If foundrane is nothing then resume

    Hello giantfan87,

    The ActiveCell should be moving to the next row. Is that not happening?

+ 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