danovkos
11-18-2010, 06:39 AM
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
:help :dunno
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
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
:help :dunno
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