+ Reply to Thread
Results 1 to 4 of 4

Mistake in code

  1. #1
    Registered User
    Join Date
    07-13-2015
    Location
    Slovakia
    MS-Off Ver
    2007, 2010, 2013
    Posts
    76

    Post Mistake in code

    Hello fellow experts,
    where is the mistake in this code? It says "Else without If" although there is If. Any ideas?

    Private Sub TextBox1_Change()
    Dim Searched As String
    Dim Found As Range
    Dim SearchRange As Range
    Set SearchRange = ActiveSheet.Range(("E14"), Range("E14").End(xlDown))
    Searched = TextBox1.Value
    If Searched = "" Then Exit Sub
    Set Found = SearchRange.Find(Searched)
    If Found Is Nothing Then MsgBox ("Name could not be found in the namelist")
    ActiveWindow.ScrollRow = Range("A14").Row
    Else: Found.Select
    End If
    ActiveWindow.ScrollRow = ActiveCell.Row
    TextBox1.Activate
    End Sub

  2. #2
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,004

    Re: Mistake in code

    Maybe this:
    Please Login or Register  to view this content.
    Last edited by Akuini; 02-23-2016 at 09:55 AM. Reason: code tag

  3. #3
    Registered User
    Join Date
    07-13-2015
    Location
    Slovakia
    MS-Off Ver
    2007, 2010, 2013
    Posts
    76

    Re: Mistake in code

    It works fine now, so where was the mistake? Am i to divide it by rows?

  4. #4
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,004

    Re: Mistake in code

    If after 'then' there is a statement then the if statement ends there (only one line without end if).
    Please Login or Register  to view this content.
    If you want to use 'end if' it becomes:
    Please Login or Register  to view this content.
    Both codes are just the same.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA, Mistake or Glicth?
    By Kramerica44 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-23-2013, 06:41 PM
  2. Where Is My Code Mistake For Listbox ?
    By blackvba in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-29-2008, 02:29 AM
  3. [SOLVED] Can somebody tell me what cause the mistake?
    By ericsson in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-16-2006, 04:00 AM
  4. VB code almost works...but can't find a minor mistake
    By NadiaR via OfficeKB.com in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-16-2006, 01:35 PM
  5. Code mistake
    By Mirko Barkovic in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-29-2005, 10:00 AM
  6. i sent by mistake
    By fish in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-11-2005, 03:06 PM

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