Consulting

Results 1 to 2 of 2

Thread: FIX code for search variable from copy excel cell or clipboard

  1. #1

    FIX code for search variable from copy excel cell or clipboard

    Hi all,
    Please. i cant figured out, how to do following:
    I want with macro search
    1) value from clipboard
    2) value which is copying (CutCopyMode is true) but i can be on other cell. I mean actually i copy cell A1, but my active cell is D5 (i want to search A1)

    Of course, if i something in clipboard and then i select copy something from sheet (A1), it will be search by point 2) so A1, because is something copying.

    i hope, that i am clear, because my bad english.

    thx for help


    [vba]
    Sub find_clipboard()
    Dim DataObj As MSForms.DataObject
    Dim a As Variant
    Dim b As Variant
    Set DataObj = New MSForms.DataObject
    DataObj.GetFromClipboard
    a = DataObj.GetText
    If Application.IsNumber(a) = True Then
    a = DataObj.GetText * 1
    End If
    If Application.CutCopyMode = xlCopy Then
    Cells.Find(What:=a, After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False).Activate
    Else
    DataObj.GetFromClipboard
    a = DataObj.GetText
    Cells.Find(What:=a, After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False).Activate
    End If
    End Sub
    [/vba]
    Last edited by Aussiebear; 11-18-2010 at 03:26 PM. Reason: Adjusted correct code tags for User

  2. #2
    nobody can help?
    maybe can help me only this,
    when i copying something (A1) and there is text, it set clipboard to variable DataVariable. If is it text (in cell A1 is text) it set to variable text what is in A1 (this is OK) but also some strange character - maybe is it CR or so..) My variable contains something like this

    how can i do from this only pure text withou any other CR?
    thx

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •