[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Position title row at top after clicking hyperlink

Posted on 2011-04-21
2
Medium Priority
?
164 Views
Last Modified: 2012-05-11
The index in the attached sheet links to the title of each study.  The only problem now is that it appears at the bottom as opposed to the top.  I am trying to prevent the need for scrolling after clicking the hyperlink.  Assistance is greatly appreciated.  Attached below is the file and pasted below is the code.
Sub create_Index()

'This code is designed to create an index file that contains a link to numbered title columns
'and a copyright column derived from the Studies tab.
'It also should create empty columns that can be edited from the Index tab itself.
'Re-applying the macro when new studies are added, should still maintain the position of the comments
'next to the correct study.

    Dim lastRow As Long, Rw As Long, i As Long
    Dim ws As Worksheet
    Dim StrSearch As String
    Dim rng As Range
   
    On Error Resume Next
    Set ws = Sheets("Index")
    On Error GoTo 0
   
    If ws Is Nothing Then
        Set ws = Sheets.Add
        ws.Name = "Index"
    End If

    Rw = ws.Range("A" & Rows.Count).End(xlUp).Row + 1
    lastRow = Sheets("studies").Range("A" & Rows.Count).End(xlUp).Row
   
    For i = 3 To lastRow
        If Len(Trim(Sheets("studies").Range("A" & i).Value)) <> 0 Then
            StrSearch = Sheets("studies").Range("A" & i).Value
           
            Set aCell = ws.Range("A1:A" & Rw).Find(What:=StrSearch, LookIn:=xlValues, _
            LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False)
           
            If aCell Is Nothing Then
                ws.Range("A" & Rw).Value = Sheets("studies").Range("A" & i).Value
                ws.Range("B" & Rw).Value = Sheets("studies").Range("B" & i).Value
                ws.Range("C" & Rw).Value = Sheets("studies").Range("D" & i).Value
                On Error Resume Next
                ws.Hyperlinks.Add Anchor:=ws.Range("B" & Rw), Address:="", SubAddress:= _
                "Studies!B" & i, TextToDisplay:=Sheets("studies").Range("B" & i).Value
                On Error GoTo 0
                Rw = Rw + 1
            End If
        End If
    Next i
   
    lastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
   
    Set rng = ws.Range("A1:E" & lastRow)
    ws.ListObjects.Add(xlSrcRange, rng, , xlYes).Name = "Table3"
    ws.ListObjects("Table3").TableStyle = "TableStyleMedium15"
   
    With ws.Cells
        .ColumnWidth = 170.14
        .RowHeight = 248.25
        .EntireColumn.AutoFit
        .EntireRow.AutoFit
    End With
End Sub

Open in new window

tosstudies-6.16.xlsm
0
Comment
Question by:rtod2
  • 2
2 Comments
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 2000 total points
ID: 35444168
I thought it was not possible but after trying finally figured it out.

This code gas to go to the sheet code area of Sheet "Studies"

Private Sub Worksheet_Activate()
    ActiveWindow.ScrollRow = ActiveCell.Row
End Sub

Open in new window


HTH

Sid
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 35444196
Here is a snapshot.

Sid
Untitled.jpg
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question