+ Reply to Thread
Results 1 to 3 of 3

simple quick question

  1. #1
    John
    Guest

    simple quick question

    I want to find the active cell in a list in another worksheet... this gets
    and error on the WhatToFind line... any ideas?

    ActiveCell.Copy
    Range("z1").Select
    ActiveCell.PasteSpecial xlPasteValues
    Range("a1").Select
    Dim rngToSearch As Range
    Dim wks As Worksheet
    Dim rngFound As Range
    Dim WhatToFind As Variant

    Application.ScreenUpdating = False
    Sheets("Contacts").Select
    Set wks = Sheets("Assignments")
    Set rngToSearch = Sheets("contacts").Columns(1)
    Set WhatToFind = wks.Range("z1").Value

    Set rngFound = rngToSearch.find(what:=WhatToFind, LookIn:=xlValues,
    lookat:=xlWhole)

    If rngFound Is Nothing Then
    MsgBox "error"
    Else
    rngFound.Select
    End If
    Application.ScreenUpdating = True
    Application.Calculation = xlCalculationAutomatic

    End Sub

  2. #2
    tiah
    Guest

    Re: simple quick question

    remove the word "set" beside the "whattofind"
    you cannot "set" a value


  3. #3
    Bob Phillips
    Guest

    Re: simple quick question

    Not tested, but you set a range not a value

    ActiveCell.Copy
    Range("z1").Select
    ActiveCell.PasteSpecial xlPasteValues
    Range("a1").Select
    Dim rngToSearch As Range
    Dim wks As Worksheet
    Dim rngFound As Range
    Dim WhatToFind As Variant

    Application.ScreenUpdating = False
    Sheets("Contacts").Select
    Set wks = Sheets("Assignments")
    Set rngToSearch = Sheets("contacts").Columns(1)
    WhatToFind = wks.Range("z1").Value

    Set rngFound = rngToSearch.find(what:=WhatToFind, LookIn:=xlValues,
    lookat:=xlWhole)

    If rngFound Is Nothing Then
    MsgBox "error"
    Else
    rngFound.Select
    End If
    Application.ScreenUpdating = True
    Application.Calculation = xlCalculationAutomatic

    End Sub

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "John" <[email protected]> wrote in message
    news:[email protected]...
    > I want to find the active cell in a list in another worksheet... this gets
    > and error on the WhatToFind line... any ideas?
    >
    > ActiveCell.Copy
    > Range("z1").Select
    > ActiveCell.PasteSpecial xlPasteValues
    > Range("a1").Select
    > Dim rngToSearch As Range
    > Dim wks As Worksheet
    > Dim rngFound As Range
    > Dim WhatToFind As Variant
    >
    > Application.ScreenUpdating = False
    > Sheets("Contacts").Select
    > Set wks = Sheets("Assignments")
    > Set rngToSearch = Sheets("contacts").Columns(1)
    > Set WhatToFind = wks.Range("z1").Value
    >
    > Set rngFound = rngToSearch.find(what:=WhatToFind, LookIn:=xlValues,
    > lookat:=xlWhole)
    >
    > If rngFound Is Nothing Then
    > MsgBox "error"
    > Else
    > rngFound.Select
    > End If
    > Application.ScreenUpdating = True
    > Application.Calculation = xlCalculationAutomatic
    >
    > End Sub




+ 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