Send Clipboard in VBA

tcnt9176

Board Regular
Joined
Jun 23, 2008
Messages
223
I am trying to add script where I can use find with a variable. I just need to modify this to find whatever I just copied to the clipboard.

Code:
    Selection.Find(What:=ClipBoard, After:=ActiveCell, LookIn:= _
        xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
        xlNext, MatchCase:=False, SearchFormat:=False).Activate
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Instead of .Activate, use .Copy.

I think...
 
Upvote 0
Sorry. I may not have explained it very good. I don't need to copy what I find. I need to find what I copied.
 
Upvote 0
Maybe like this

Code:
Range("Z1000").PasteSpecial Paste:=xlPasteValues
 Selection.Find(What:=Range("Z1000").Value, After:=ActiveCell, LookIn:= _
        xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
        xlNext, MatchCase:=False, SearchFormat:=False).Activate
 
Upvote 0
So what you gave me is working for the first find but then I receive run-time error '91': Object Variable or With block variable not set.

I tried resetting the macro etc and it always works on the first find but then I receive this error on all other finds in the script.

I tried googling etc but have not really found this error involving Find.
 
Upvote 0
Here is the code.

Code:
Do
    If ActiveCell.Value <> "" Then
    
    ActiveCell.Offset(0, -1).Range("A1:B1").Copy
    Windows("ORS Aging Report - June 2011.xlsx").Activate
    Range("I1:J1").PasteSpecial Paste:=xlPasteValues
    Columns("A:A").Select
    Selection.Find(What:=Range("I1").Value, After:=ActiveCell, LookIn:= _
        xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
        xlNext, MatchCase:=False, SearchFormat:=False).Activate
    ActiveCell.Select
    Selection.Find(What:=Range("J1").Value, After:=ActiveCell, LookIn:= _
        xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
        xlNext, MatchCase:=False, SearchFormat:=False).Activate
    ActiveCell.Select
    Windows("D & L Monthly Reporting.xlsm").Activate
    ActiveCell.Offset(0, 1).Range("A1:B1").Copy
    Windows("ORS Aging Report - June 2011.xlsx").Activate
    ActiveCell.Offset(0, 7).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Windows("D & L Monthly Reporting.xlsm").Activate
    ActiveCell.Offset(1, 0).Select
    Application.CutCopyMode = False
    
    Else
        Exit Do
    End If
Loop
 
Upvote 0
That will fail if your first Find isn't found. I don't really understand what you are trying to do but try FindNext. There is a good example for that in the Help file.
 
Upvote 0

Forum statistics

Threads
1,224,604
Messages
6,179,857
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top