search and copy columns to clipboard

tomleitch

Board Regular
Joined
Jan 3, 2012
Messages
189
Hi all,

I have some code that I have butchered to try and find values in a column on my spreadsheet.

Basically what I am trying to do is that and cell in column H that has a matching date, I want to copy some columns from that row - to end up pasting them into a new sheet.

At the minute it highlights the matching cells yellow.... but instead of that I want it to copy cells from columns A, B and H from that row and have all the combined info in the clipboard so that I can paste into an email body....

Can anyone help?

Many thanks - Tom

Code:
Dim fnd As Date, FirstFound As String
Dim FoundCell As Range, rng5 As Range
Dim myRange As Range, LastCell As Range
'What value do you want to find (must be in string form)?
fnd = Sheets("SETTINGS").Range("A14").Value
MsgBox fnd
Set myRange = Sheets("OPS PLANNER").Range("H10:H5010")
Set LastCell = myRange.Cells(myRange.Cells.Count)
Set FoundCell = myRange.Find(what:=fnd, after:=LastCell)
'Test to see if anything was found
If Not FoundCell Is Nothing Then FirstFound = FoundCell.Address Else GoTo NothingFound

Set rng5 = FoundCell

Do Until FoundCell Is Nothing
Set FoundCell = myRange.FindNext(after:=FoundCell)
Set rng5 = Union(rng5, FoundCell)
If FoundCell.Address = FirstFound Then Exit Do
Loop


'Highlight Found cells yellow
Interior.Color = RGB(255, 255, 0)
GoTo 100


'Error Handler
NothingFound:
MsgBox "No values were found in this worksheet"
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,224,827
Messages
6,181,200
Members
453,022
Latest member
RobertV1609

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