Scroll sheet to find value based on another cell.

cunningAce

Board Regular
Joined
Dec 21, 2017
Messages
91
Office Version
  1. 365
Platform
  1. Windows
Hi All,

Hoping someone can help me with this.

I assume this will require VBA which i have little knowledge of,

In the below example. I want to automatically scroll to and select the cell of the equivalent Week number as the user inserts into B3.
So the result would be, M3 is now selected and had M3 not been visible on the current page view, for the sheet to have scrolled across to put it in view.

Thank you in advance for your time.

ABCDEFGHIJKLMNOPQRSTUVW
SearchWeek 1Week 2Week 3Week 4Week 5Week 6Week 7Week 8Week 9Week 10Week 11Week 12Week 13Week 14Week 15Week 16Week 17Week 18Week 19Week 20

<tbody>
[TD="align: center"]3[/TD]

[TD="align: right"]10[/TD]
[TD="align: right"][/TD]

</tbody>
Sheet1

 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
right click on worksheet tab and select "view code"

Paste this in the VBA Editor when it appears

Code:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)


' only proceed if cell B3 is changed
If Intersect(Target, Range("B3")) Is Nothing Then Exit Sub


' switch events off whilst processing worksheet, to prevent accidental terminal loops later
Application.EnableEvents = False


' ignore any problems encountered, e.g. where invalid text entered - i.e. do not allow code to crash
On Error Resume Next


' create search term
Dim strSearch As String: strSearch = "Week " & Target.Value


' jump to first cell found containing search term - may need to restrict this to say Row 1, rather than all cells, and change [After:=] to start from say range("A1")
Cells.Find(What:=strSearch, After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate
On Error GoTo 0


' switch events back on
Application.EnableEvents = True


End Sub
 
Upvote 0
right click on worksheet tab and select "view code"

Paste this in the VBA Editor when it appears

Code:
Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)


' only proceed if cell B3 is changed
If Intersect(Target, Range("B3")) Is Nothing Then Exit Sub


' switch events off whilst processing worksheet, to prevent accidental terminal loops later
Application.EnableEvents = False


' ignore any problems encountered, e.g. where invalid text entered - i.e. do not allow code to crash
On Error Resume Next


' create search term
Dim strSearch As String: strSearch = "Week " & Target.Value


' jump to first cell found containing search term - may need to restrict this to say Row 1, rather than all cells, and change [After:=] to start from say range("A1")
Cells.Find(What:=strSearch, After:=ActiveCell, LookIn:=xlFormulas, _
        LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate
On Error GoTo 0


' switch events back on
Application.EnableEvents = True


End Sub

Baitmaster this is great, thank you so much
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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