Results 1 to 4 of 4

Having trouble using clipboard data in Find function

Threaded View

RollerRagerMD Having trouble using... 06-28-2013, 02:00 PM
Leith Ross Re: Having trouble using... 06-28-2013, 02:14 PM
RollerRagerMD Re: Having trouble using... 06-28-2013, 02:29 PM
Leith Ross Re: Having trouble using... 06-28-2013, 02:58 PM
  1. #1
    Registered User
    Join Date
    06-28-2013
    Location
    Fort Mill, SC
    MS-Off Ver
    Excel 2010
    Posts
    17

    Having trouble using clipboard data in Find function

    When I execute this code, I get this error: Runtime Error 438, Object doesn't support this property or method

    Sub LastRowInOneColumn()
    'Find the last used row in a Column: column A in this example
    Sheets("Sheet1").Select
        Dim LastRow As Long
        With ActiveSheet
            LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
        End With
        Cells(LastRow, 1).Select
        Dim MyData As DataObject
        Dim TMCNumber As String
        TMCNumber = ActiveCell.Value
        Set MyData = New DataObject
        MyData.SetText TMCNumber
        MyData.PutInClipboard
        
        MyData.GetFromClipboard
        Sheets("Sheet2").Select
        
        Cells.Find(What:=MyData, After:=ActiveCell, LookIn:=xlFormulas, _
            LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False).Activate
    End Sub
    Basically, what I'm trying to do is grab the value of the first cell of the last row in Sheet1, then find the cell with that value in Sheet2. I put a breakpoint in "MyData.GetFromClipboard" and the code seems to crash in the Cells.Find block. I copied that block from a macro I recorded where I manually opened the Find function and looked for a value, then just replaced the value in the macro with the name of the DataObject variable.
    Last edited by Leith Ross; 06-28-2013 at 02:11 PM. Reason: Added Code Tags

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