+ Reply to Thread
Results 1 to 6 of 6

copy find-paste

Hybrid View

  1. #1
    Registered User
    Join Date
    12-16-2008
    Location
    slo
    Posts
    3

    Question copy find-paste

    Hello,

    I would like to create macro, where it would on macro run copy text from active cell and find that value in another sheet (in column H) and select that cell.

    What I did is this:
        Selection.Copy
        Sheets("sheet2").Select
        Columns("H:H").Select
        Cells.Find(What:=Paste, LookAt:=xlPart, SearchOrder:=xlByColumns).Activate
    But this results in empty cell in the last non empty row in column A

    Thanks for help,
    Vito.
    Last edited by v|t0; 12-16-2008 at 09:27 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    This is a bit crude but should do what you want. Note it will error if more than one cell is selected
    Sheets("sheet2").Columns("H:H").Find(What:=Selection.Value, LookAt:=xlPart, _
            SearchOrder:=xlByColumns).Activate
    Hope that helps.

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

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    12-16-2008
    Location
    slo
    Posts
    3
    Thanks for prompt answer, but it did not help.

    Error message is something like:
    "Run-time error '1004'
    Activate Method of Range class failed
    Any suggestions?

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    This will do what you want

     Dim cl     As Range
        Dim sFind  As String
    
        sFind = Selection.Value
        With Sheets("sheet2")
            Set cl = .Columns("H:H").Find(What:=sFind, LookAt:=xlPart)
            If Not cl Is Nothing Then Application.Goto .Range(cl.Address)
        End With

  5. #5
    Registered User
    Join Date
    12-16-2008
    Location
    slo
    Posts
    3
    Great, works like a charm!

    Thanks!

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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