Explanation of this code please

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,735
Office Version
  1. 2007
Platform
  1. Windows
Hi,
The following code is working fine & supplied below.
I have fixed headers at Row 7
My current row page count is 898
When i come to this worksheet called POSTAGE this code runs & i see the last 10rows of which i have values in cells.
So example.
Headers at row 7
The next row i see is the row 889 & goes down the page to row 898
The rows 899 900 901 902 etc etc is shown but empty.
What i am in need of is when i come to this page as opposed to seeing the last 10 rows with values is to see the last 16 rows with values.
Changing the code below from UP:=10 to UP:=16 made no difference as i was still able to see rows 889 to 898, so im a little confused

Have a nice day



Code:
Private Sub BottomOfPage_Click()    Application.GoTo Sheets("POSTAGE").Range("A" & Rows.Count).End(xlUp), True
    ActiveWindow.SmallScroll UP:=10
End Sub
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Try:
Code:
Private Sub BottomOfPage_Click() 
    Application.GoTo Sheets("POSTAGE").Range("A" & Rows.Count).End(xlUp).offset(-15), True    
End Sub
 
Upvote 0
How about
Code:
Private Sub BottomOfPage_Click()
Application.Goto Sheets("POSTAGE").Range("A" & Rows.Count).End(xlUp).Offset(-16), True
End Sub
 
Upvote 0
This should show the last 16 rows.
Code:
Private Sub BottomOfPage_Click()    
    Application.GoTo Sheets("POSTAGE").Range("A" & Rows.Count).End(xlUp).Offset(-16), True
End Sub
 
Last edited:
Upvote 0
Hi,
That also has no affect when i chnage the 16 to 3 or 22 etc
A userform opens when i come to this page but i removed that code and still the -16 etc has no affect ???
 
Upvote 0
No user forms were mentioned in the opening post.

What triggers the code, is it attached to an object or to a button on the User Form (which you've now disabled) or does an Event trigger it?
 
Last edited:
Upvote 0
In that you have something else going on, is there any code after the 2 lines you showed us?
 
Upvote 0
This is used to open the userfoerm

Code:
Private Sub Worksheet_Activate()PostageTransferSheet.Show
End Sub

But even with that code removed, save page & close then open again still when i visit this page there is no change to the rows viewed
 
Upvote 0
Here is all the code from the POSTAGE worksheet



Code:
Private Sub BottomOfPage_Click()Application.Goto Sheets("POSTAGE").Range("A" & Rows.Count).End(xlUp).Offset(-16), True
End Sub


Private Sub ComboBox1_Change()
  Dim r As Range
  Set r = Range("B7", Range("B" & Rows.Count).End(xlUp)).SpecialCells(xlCellTypeVisible) _
    .Find(ComboBox1.Value)
  If Not r Is Nothing Then r.Select
  ComboBox1.ListIndex = -1
End Sub
Private Sub ComboBox1_DropButt*******()
  RangeUniqueSortFillControl Range("B7", Range("B" & Rows.Count).End(xlUp)).SpecialCells(xlCellTypeVisible), Sheet13.ComboBox1
End Sub
Private Sub CommandButton1_Click()
PostageTransferSheet.Show
End Sub
Private Sub SortCustomerAZ_Click()
    
    Dim x As Long
    
    Application.ScreenUpdating = False
    
    With Sheets("POSTAGE")
        If .AutoFilterMode Then .AutoFilterMode = False
        x = .Cells(.Rows.Count, 1).End(xlUp).Row
        
        .Range("A8:I" & x).Sort key1:=Range("A8"), order1:=xlAscending, Header:=xlGuess
        
    End With
                      
    ActiveWorkbook.Save
    
    Application.ScreenUpdating = True
    Sheets("POSTAGE").Range("A8").Select
    
End Sub
Private Sub TopOfPage_Click()
Range("A8").Select
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
    With Target
        If .Column = 1 Then Exit Sub
        If .Column = 7 Then Exit Sub
        If .Count = 1 And Not .HasFormula Then
            Application.EnableEvents = False
            .Value = UCase(.Value)
            Application.EnableEvents = True
        End If
    End With
End Sub
Private Sub DHL_Click()
ActiveWorkbook.FollowHyperlink Address:="http://www.dhl.co.uk/en/express/tracking.html", NewWindow:=True
End Sub


Private Sub LabelButton_Click()
TrackingLabel.Show
End Sub


Private Sub My_Hermes_Click()
ActiveWorkbook.FollowHyperlink Address:="https://www.myhermes.co.uk/tracking-results.html", NewWindow:=True
End Sub


Private Sub ROYALMAILButton_Click()
ActiveWorkbook.FollowHyperlink Address:="https://www.royalmail.com/track-your-item", NewWindow:=True
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim myStartCol As String
    Dim myEndCol As String
    Dim myStartRow As Long
    Dim myLastRow As Long
    Dim myRange As Range


    If Target.Cells.Count > 1 Then Exit Sub
    
    Application.ScreenUpdating = False
    
'   *** Specify columns to apply this to ***
    myStartCol = "A"
    myEndCol = "I"


'   *** Specify start row ***
    myStartRow = 8
    
'   Use first column to find the last row
    myLastRow = Cells(Rows.Count, myStartCol).End(xlUp).Row + 1
    
'   Build range to apply this to
    Set myRange = Range(Cells(myStartRow, myStartCol), Cells(myLastRow, myEndCol))
    
'   Clear the color of all the cells in range
    myRange.Interior.ColorIndex = 6
    
'   Check to see if cell selected is outside of range
    If Intersect(Target, myRange) Is Nothing Then Exit Sub
    
'   Highlight the row and column that contain the active cell
    Range(Cells(Target.Row, myStartCol), Cells(Target.Row, myEndCol)).Interior.ColorIndex = 8
    Target.Interior.Color = vbGreen
    Application.ScreenUpdating = True


End Sub


Private Sub Worksheet_Activate()
PostageTransferSheet.Show
End Sub
 
Upvote 0
In that you have something else going on, is there any code after the 2 lines you showed us?

Hi,
Just had an emergency so need to pop out.

The code in post 1 is also on another worksheet and works fine when i change the value.

Back in a few hours
Thanks
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,208
Members
452,618
Latest member
Tam84

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