Scroll to cell value

tjktm

New Member
Joined
Mar 2, 2016
Messages
31
My spreadsheet is set up to scroll from a button to a certain row number. That row contains specific information. However, when new rows are added or deleted, the button scrolls to rows above or below the correct row. I have the following code now:

Sub View_9()
' View_Total Macro
ActiveWindow.ScrollRow = 298

This code works great as long as no rows are added or deleted.

Need code to scroll to a variable cell with a specific value in column A. The specific value will be "R.1" , "R.2", etc. . Those values could be changed if they complicate the code.

Thanks for any help

TJ
 
Ok, my suggestion was based on your post#3
When i press my command button labeled "R.8" , i need it to scroll to the row that has "R.8" in Column A.
do you want the button called 1 to take you to R.1 & the button called 2 to take you to R.2 etc?
 
Upvote 0

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
In that case try
Code:
Sub ScrollToRow()
   Dim Fnd As Variant, fndRng As Range
   
   Fnd = "R." & ActiveSheet.Shapes(Application.Caller).AlternativeText
   If Fnd = "" Then Exit Sub  'cancel was clicked
   Set fndRng = Columns("A").Find(Fnd)
   If Not fndRng Is Nothing Then
       ActiveWindow.ScrollRow = fndRng.Row
   Else
       MsgBox "Can't find " & Fnd & " in column A"
   End If
End Sub
 
Upvote 0
This is a good description of how to use a single code for multiple buttons on a userform.

http://spreadsheetpage.com/index.php/site/tip/handle_multiple_userform_buttons_with_one_subroutine/

You need to modify it a bit to use activeX buttons on a worksheet. Something like this, maybe in workbook activate or some other way to trigger it:

Code:
Private Sub Worksheet_Activate()


    Dim ButtonCount As Integer
    Dim objX As Object


    ButtonCount = 0
    
    For Each objX In ActiveSheet.OLEObjects
    
        If TypeName(objX.Object) = "CommandButton" Then
             
            If objX.Name <> "OKButton" Then 'Skip the OKButton
                ButtonCount = ButtonCount + 1
                ReDim Preserve Buttons2(1 To ButtonCount)
               Set Buttons2(ButtonCount).ButtonGroup = objX.Object
            End If
            
        End If
        
    Next objX


End Sub
 
Upvote 0

Forum statistics

Threads
1,215,943
Messages
6,127,826
Members
449,411
Latest member
adunn_23

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