There are some questions that need to be answered.
What/where is this object?
Is it on a worksheet or is it on a userform?
Is it a listbox or combobox/dropdown or is it from data|validation.
If it's on a worksheet, did you create it using the controls from the Control
toolbox toolbar or from the Forms Toolbar.
The code would be different in each case.
I used a combobox from the controltoolbox toolbar on a worksheet and I could
doubleclick on that control and paste this code in the code window. I could use
the same code behind the userform.
Option Explicit
Dim blkProc As Boolean
Private Sub ComboBox1_Change()
Dim testWks As Worksheet
If blkProc = True Then Exit Sub
If Me.ComboBox1.Value = "" Then
'do nothing
Else
Set testWks = Nothing
On Error Resume Next
Set testWks = ThisWorkbook.Worksheets(Me.ComboBox1.Value)
On Error GoTo 0
If testWks Is Nothing Then
MsgBox "Please fix rowsource"
Else
testWks.Activate
Application.Goto testWks.Range("a1"), Scroll:=True
End If
blkProc = True
Me.ComboBox1.ListIndex = -1
blkProc = False
End If
End Sub
====
If you used a dropdown from the Forms toolbar, you could assign this macro to
the dropdown:
Option Explicit
Sub DDChange()
Dim myDD As DropDown
Dim testWks As Worksheet
Set myDD = ActiveSheet.DropDowns(Application.Caller)
If myDD.ListIndex < 1 Then
'do nothing
Else
Set testWks = Nothing
On Error Resume Next
Set testWks = ThisWorkbook.Worksheets(myDD.List(myDD.ListIndex))
On Error GoTo 0
If testWks Is Nothing Then
MsgBox "Please fix rowsource"
Else
testWks.Activate
Application.Goto testWks.Range("a1"), Scroll:=True
End If
End If
myDD.ListIndex = 0
End Sub