Help with wiriting macros

jlaessig

New Member
Joined
Jul 25, 2018
Messages
4
Hi, I am very new to writing macros and am hoping someone with more knowledge and experience can help me! I want to write something that will essentially replace the find and select function between two worksheets. I have a pivot table with sample numbers in column A on a tab called "Test on Time" and I would like to be able to double click a sample number and have it find the same sample number on another worksheet called "KPI Report" and highlight that row.

This may be super easy, but I have no idea. Please help!

Jessica
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Jessica,

Welcome to the Board.

You might consider the following...

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim sample As String, found As Range
If Not Intersect(Target, Columns(1)) Is Nothing Then
    sample = Target.Value
    Set found = Sheets("KPI Report").Cells.Find(What:=sample, After:=Cells(1, 1), LookIn:=xlFormulas, _
        LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False)
    If Not found Is Nothing Then
        Sheets("KPI Report").Activate
        found.EntireRow.Select
    Else
        MsgBox "The search item was not found."
    End If
End If
End Sub

The code should be pasted into the Test on Time sheet module.

Cheers,

tonyyy
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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