Lookup value in cell and find that value in other worksheet.

SwiftM

New Member
Joined
Sep 11, 2021
Messages
19
Office Version
  1. 365
Platform
  1. Windows
Hi Excel Gurus,

I am already learning a lot from you all but need you to teach me something else!

1666164747743.png


I am creating a sort of Crime Log for a project. The screenshot above is from a worksheet called "Crime". I have another worksheet called "CrimeLog".

As you can see above, in cell B3 is a reference number for crime logs. And the next crime reference number is inserted automatically using an already made code in the next empty cell in column B. This reference number is also inserted automatically in the next available cell in Range A1:Z1 in worksheet "CrimeLog".

So far, when I click the little blue plus buttons on the right (J3), it looks up value in Cell B3 and finds it in range A1:Z1 in worksheets "CrimeLog" where the Application.Goto function is activated.

I have done this with the following code:

Sub Match_Example1()


Dim xlRange As Range
Dim xlCell As Range
Dim xlSheet As Worksheet
Dim valueToFind

valueToFind = Sheets("marswi").Range("B3")
Set xlSheet = ActiveWorkbook.Worksheets("marswiLog")
Set xlRange = xlSheet.Range("B1:AZ1")

For Each xlCell In xlRange
If xlCell.Value = valueToFind Then
Application.Goto Reference:=xlCell


Else
End If
Next xlCell
End Sub

The problem I am having is that I do not want a separate code for each of the little blue buttons, for example, the plus sign in cell J3 looks up B3, and the next plus sign in cell J4 looks up B4 etc.

Is there a way in which i can use just ONE code for the plus signs so that it looks up the value in column B adjacent to a plus sign, and takes you to the found value in worksheet "CrimeLog".

I hope i have explained this well enough!!!

Any help would be much appreciated.

Kind regards,
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

Forum statistics

Threads
1,214,614
Messages
6,120,520
Members
448,968
Latest member
Ajax40

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