Automation from Macro

mole999

Well-known Member
Joined
Oct 23, 2004
Messages
10,524
Office Version
  1. 2019
  2. 2016
  3. 2013
Platform
  1. Windows
I have a list of sheet names in Col A of INDEX, each of which is preceded with a ',
there are 37 unique IDs

I want a SUM of cells AN2:AN600 from each of the sheets as

=SUM('NC (119 of 510)'!$AN$2:$AN$600)

I can create these manual

I'm trying to concoct a formula that will combine the sheet name and range to then be able to drag down, ultimately it will be in a macro to automate this step

can someone point me
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
So you want a formula or VBA? A formula for each sheet or a total? Sounds like you want INDIRECT if you want a formula.
 
Upvote 0
Agree that INDIRECT is the way to go, I just can't get it to assemble as a drag down using column A (because the numbers change I can't just construct something simple it has to relate to the Tab name and the Index name (minus the '), everything I have tried throws an error and I can't hit the right construct
 
Upvote 0
So the tabs are all called 'NC (Something of Something)'? What do you have in Col A of the index sheet?
 
Upvote 0
Column A is the names of the Tabs

its a index built after each sheet is added from

Name the Sheets, from a loop
Code:
Selector = "NC"

...CODE..............................

    Dim LastRow2 As Long
    LastRow2 = ActiveSheet.Range("A10000").End(xlUp).Row
Dim SUMMER As Long

    SUMMER = ActiveSheet.Range("A1")
    ActiveSheet.Name = Selector & " (" & SUMMER & " of " & LastRow2 & ")"
           
    Sheets(1).Select

so they are an exact match

Then, Create the INDEX
Code:
Private Sub IndexIt()
    Dim WS As Worksheet, WsInd As Worksheet, lStartRow%, lStartCol, sBackRange As String
    '##1: Where should the back-to-index-page link be, change if necessary
    sBackRange = "A1"
    
    '  ActiveWorkbook.Sheets.Add after:=Worksheets(Worksheets.Count)
   
    'Set Ws = Worksheets("INDEX")
    Set WS = Worksheets.Add(Before:=Worksheets(1))
    ActiveSheet.Name = "INDEX"
     
    lStartRow = Selection.Row
    lStartCol = Selection.Column
     
    Set WsInd = ActiveSheet
     
    'Add the links
    For Each WS In Worksheets
        If WS.Name <> WsInd.Name Then
            WsInd.Hyperlinks.Add WsInd.Cells(lStartRow, lStartCol), "", "'" & WS.Name & "'!A1"
            WsInd.Cells(lStartRow, lStartCol).Value = WS.Name
            lStartRow = lStartRow + 1
             
            '##2: Add link back to index, comment the following 2 lines if you don't want this part
            WS.Hyperlinks.Add WS.Range(sBackRange), "", "'" & WsInd.Name & "'" & "!A1"
            WS.Range(sBackRange).Value = "Back to Index"
        End If
    Next WS
     
    WsInd.Activate
    
    Sheets("INDEX").Select
    percentages
End Sub
 
Upvote 0
So it should be this if im understanding:

=SUM(INDIRECT("'"&A1&"'!$AN$2:$AN$600"))

And just drag it down.
 
Upvote 0
That's it exactly, I think I was missing a speech mark, and couldn't resolve it
 
Upvote 0

Forum statistics

Threads
1,215,695
Messages
6,126,263
Members
449,307
Latest member
Andile

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