Explanation of this code please

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,224
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
 
Quickly found it.

This removed allows the code to work.
If i paste it back then it fails to work.
So can the code i wish to work run BEFORE the code the code starts.

Thanks



Code:
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
 
Upvote 0

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
That does not affect the the code that we posted, it just changes the colour of some cells.
 
Upvote 0
You are correct as it now works,many thanks.

I have this bug now & then which kills things until i save & open work book again of which im still looking for.

Have a nice day
 
Upvote 0
Glad it's sorted & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,520
Messages
6,120,013
Members
448,935
Latest member
ijat

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