+ Reply to Thread
Results 1 to 4 of 4

Application GoTo

  1. #1
    ufo_pilot
    Guest

    Application GoTo

    Hello all
    Before the holidays. this code worked
    after the magic of christmas is gone, so is the integrity of this code.
    What went wrong?
    Through a drop down menu, the user selects a name which appears in C2
    upon clicking the "View Cert" button it takes you to the name that matches
    C2 this will be anywhere between A66:A2020
    now it does nothing - no errors either
    Stumped



    Sub ViewCert()
    Dim rngToSearch As Range
    Dim rngFound As Range
    Dim wks As Worksheet
    Set wks = ActiveSheet
    Set rngToSearch = Worksheets("Certs").Range("A66:A2020")
    Set rngFound = rngToSearch.Find(Range("C2"))

    If Not rngFound Is Nothing Then
    Application.Goto Range(rngFound.Address), True
    End If
    End Sub

  2. #2
    Dave Peterson
    Guest

    Re: Application GoTo

    First thing I'd try is changing this:
    Application.Goto Range(rngFound.Address), True
    to
    Application.Goto rngFound, True

    rngFound.address returns a string (Say x99)
    range(x99) will refer to the activesheet--not Certs.




    ufo_pilot wrote:
    >
    > Hello all
    > Before the holidays. this code worked
    > after the magic of christmas is gone, so is the integrity of this code.
    > What went wrong?
    > Through a drop down menu, the user selects a name which appears in C2
    > upon clicking the "View Cert" button it takes you to the name that matches
    > C2 this will be anywhere between A66:A2020
    > now it does nothing - no errors either
    > Stumped
    >
    > Sub ViewCert()
    > Dim rngToSearch As Range
    > Dim rngFound As Range
    > Dim wks As Worksheet
    > Set wks = ActiveSheet
    > Set rngToSearch = Worksheets("Certs").Range("A66:A2020")
    > Set rngFound = rngToSearch.Find(Range("C2"))
    >
    > If Not rngFound Is Nothing Then
    > Application.Goto Range(rngFound.Address), True
    > End If
    > End Sub


    --

    Dave Peterson

  3. #3
    Jim Thomlinson
    Guest

    RE: Application GoTo

    Give this a whirl... Find is subject to the settings last selected using Find
    in Excel. As a guess some of them have been changed since you last ran the
    code

    Sub ViewCert()
    Dim rngToSearch As Range
    Dim rngFound As Range
    Dim wks As Worksheet
    Set wks = ActiveSheet
    Set rngToSearch = Worksheets("Certs").Range("A66:A2020")
    Set rngFound = rngToSearch.Find(What:=wks.Range("C2"), _
    LookAt:=xlPart, MatchCase:=false)

    If Not rngFound Is Nothing Then
    Worksheets("Certs").activate
    rngFound.activate
    Else
    msgbox "Not Found"
    End If
    End Sub
    --
    HTH...

    Jim Thomlinson


    "ufo_pilot" wrote:

    > Hello all
    > Before the holidays. this code worked
    > after the magic of christmas is gone, so is the integrity of this code.
    > What went wrong?
    > Through a drop down menu, the user selects a name which appears in C2
    > upon clicking the "View Cert" button it takes you to the name that matches
    > C2 this will be anywhere between A66:A2020
    > now it does nothing - no errors either
    > Stumped
    >
    >
    >
    > Sub ViewCert()
    > Dim rngToSearch As Range
    > Dim rngFound As Range
    > Dim wks As Worksheet
    > Set wks = ActiveSheet
    > Set rngToSearch = Worksheets("Certs").Range("A66:A2020")
    > Set rngFound = rngToSearch.Find(Range("C2"))
    >
    > If Not rngFound Is Nothing Then
    > Application.Goto Range(rngFound.Address), True
    > End If
    > End Sub


  4. #4
    Dave Peterson
    Guest

    Re: Application GoTo

    And that string looks more like: "$X$99"
    But there still is not worksheet associated with that string.

    By using the range variable itself, you get that range's parent (worksheet),
    too.

    Dave Peterson wrote:
    >
    > First thing I'd try is changing this:
    > Application.Goto Range(rngFound.Address), True
    > to
    > Application.Goto rngFound, True
    >
    > rngFound.address returns a string (Say x99)
    > range(x99) will refer to the activesheet--not Certs.
    >
    > ufo_pilot wrote:
    > >
    > > Hello all
    > > Before the holidays. this code worked
    > > after the magic of christmas is gone, so is the integrity of this code.
    > > What went wrong?
    > > Through a drop down menu, the user selects a name which appears in C2
    > > upon clicking the "View Cert" button it takes you to the name that matches
    > > C2 this will be anywhere between A66:A2020
    > > now it does nothing - no errors either
    > > Stumped
    > >
    > > Sub ViewCert()
    > > Dim rngToSearch As Range
    > > Dim rngFound As Range
    > > Dim wks As Worksheet
    > > Set wks = ActiveSheet
    > > Set rngToSearch = Worksheets("Certs").Range("A66:A2020")
    > > Set rngFound = rngToSearch.Find(Range("C2"))
    > >
    > > If Not rngFound Is Nothing Then
    > > Application.Goto Range(rngFound.Address), True
    > > End If
    > > End Sub

    >
    > --
    >
    > Dave Peterson


    --

    Dave Peterson

+ 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