We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


Update fixes needed

Medium Priority
Last Modified: 2012-05-11
Updates, whether in the Study tab or in the Index tab, should be correctly reflected, and next to the correct study whenever the macro is re-run.
Sub create_Index()

'This code is designed to
'1. Create an index file that contains a link to numbered title columns.
'2. Add copyright copyright information from the same row.
'3. Create empty columns that can be edited from the Index tab itself.

'Re-applying the macro when new studies are added, should still maintain this information
'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
    On Error Resume Next
    Set rng = ws.Range("A1:E" & lastRow)
    ws.ListObjects.Add(xlSrcRange, rng, , xlYes).Name = "Table3"
    ws.ListObjects("Table3").TableStyle = "TableStyleMedium15"
    On Error GoTo 0
    With ws.Cells
        .ColumnWidth = 170.14
        .RowHeight = 248.25
    End With
End Sub

Open in new window

Watch Question

Ted, Which columns need to be updated in the Index Sheet? Col C?



Yes.  The columns next to see need to accept new information as well, even as new data is added to the Study tab.
>>> The columns next to see need to accept new information as well,

So D and E in Index should pick up values from E and F from Studies?



Not exactly.  D and E in the Index are just for the Index.
Unlock this solution and get a sample of our free trial.
(No credit card required)


Great stuff!
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.