VBA Scroll to row with Match

12Rev79

New Member
Joined
Mar 2, 2021
Messages
40
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Dear Experts,

I have a ComboBox1 with fillrange: A12:A376 and linkedcell: D1
my ComboBox1 has this code Range("D1").Value = ComboBox1.Value

Note: range A12:A376 has number value from 1 to 365

I need a code that scroll to a row after a Match as code below
-----------------
Private Sub ComboBox1()
Dim myRange As Range
Dim myRow As Variant
Set myRange = Range("A12:A376")

myRow = Application.Match("E1", myRange, False)

If Not IsError(myRow) Then
ActiveWindow.ScrollRow = myRow
' and then select/activate the cell:
Application.GoTo Cells(myRange, myRow)
Else
' The value is not found in the range, so inform you:
MsgBox "Not found!"
End If
End Sub
---------------

the code only excute the MsgBox

Please any help.

Thanks in advance,
12Rev79
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
If the linked cell is D1 why are you matching E1?
 
Upvote 0
If the linked cell is D1 why are you matching E1?

Sorry my mistake, it was during my testing the code

Private Sub ComboBox1()
Dim myRange As Range
Dim myRow As Variant
Set myRange = Range("A12:A376")

myRow = Application.Match("D1", myRange, False)

If Not IsError(myRow) Then
ActiveWindow.ScrollRow = myRow
' and then select/activate the cell:
Application.GoTo Cells(myRange, myRow)
Else
' The value is not found in the range, so inform you:
MsgBox "Not found!"
End If
End Sub
 
Upvote 0
Try
VBA Code:
myRow = Application.Match(Range("D1").value, myRange, False)
 
Upvote 0
Thank you very much Fluff, however I want the code that go to the Row that match D1 to myRange (A12:A376)
myRange are number from 1 to 365, please can you help me figure out.

Let say I select 35 it will match on myRange and select on 35 instead of A35.

Thanks again and in advance.
 
Upvote 0
What type of combobox is it?
Form Control, ActiveX or is it on a userform?
 
Upvote 0
Ok how about
VBA Code:
Private Sub ComboBox1_Click()
   Range("A" & Me.ComboBox1.ListIndex + 12).Activate
End Sub
 
Upvote 0
Solution
Ok how about
VBA Code:
Private Sub ComboBox1_Click()
   Range("A" & Me.ComboBox1.ListIndex + 12).Activate
End Sub
Thank you both code works will but for now I just used the first one you gaved and make +11 in the code.
myRow = Application.Match(Range("D1").value, myRange, False)+11

Thank you so much Fluff for your kind help appreciated.

Regards,
12Rev79
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,920
Messages
6,122,272
Members
449,075
Latest member
staticfluids

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