part of macro not running

rjplante

Well-known Member
Joined
Oct 31, 2008
Messages
574
Office Version
  1. 365
Platform
  1. Windows
I have created a macro to scroll to the row that begins with the letter selected. I had this working great before lunch. I copied the macro and the activeX field over to another workbook. Now the part where it scroll to the selected letter row does not work. If the search cell is blank, it will scroll to the home row just fine. What is going on? Why won't the GoRow portion work any more?

Thanks for the help.

Robert

Code:
    Dim GoRow As Long
    Dim HomeRow As Long
    
    Application.ScreenUpdating = False
    Sheets("All Agreements").Unprotect


    GoRow = ActiveWorkbook.Sheets("All Agreements").Range("E8:E1000000").Find(Sheets("All Agreements").Range("AJ1").Value & "*", , , , , , False).Row
    HomeRow = Sheets("All Agreements").Range("E8").Row
    
'   Scroll to row of selected letter
    If Sheets("All Agreements").Range("AJ1").Value = "" Then
        With ActiveWindow
            .ScrollRow = HomeRow
        End With
    Else
        With ActiveWindow
            .ScrollRow = GoRow
        End With
    End If


    With Sheet1
        .ComboBox2.ListIndex = -1
    End With
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Correction: Now is seems to go to the cell where the selected letter first appears, Which is usually somewhere in the A's. Still confused.
 
Upvote 0
Possibly the find target is not found. Here's a modification to your code to replace the GoRow line that will help to diagnose the problem:
Code:
Dim GoCell As Range
Set GoCell = ActiveWorkbook.Sheets("All Agreements").Range("E8:E1000000").Find(Sheets("All Agreements").Range("AJ1").Value & "*", _
    , , , , , False)
If GoCell Is Nothing Then
    MsgBox "Not found"
Else
    GoRow = GoCell.Row
End If
'rest of code
 
Upvote 0
Thanks for the suggestion. I implemented your diagnostic fix, to no avail. It will still just go the first row where my selected letter appears. Still in the A section. A mystery even more confusing.
 
Upvote 0
Thanks for the suggestion. I implemented your diagnostic fix, to no avail. It will still just go the first row where my selected letter appears. Still in the A section. A mystery even more confusing.
I have no idea what you are trying to do or what the selected letter is all about so afraid I can't provide anything more.
 
Upvote 0
I have an ActiveX comboBox than has a drop down menu of the alphabet. This is linked to a cell in my spreadsheet. I spreadsheet has a column of company names. I would like to select a letter from the menu, click on a button and have the first row of the company name that begins with that letter be brought to the top. So if I select the letter L and click the button, the row with Larson Companies will appear in the first row below row 7, which is frozen. This is just supposed to be a quick navigation based on the letter that starts the text in Column E.
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,271
Members
452,628
Latest member
dd2

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