ZoopZoop
New Member
- Joined
- Jul 9, 2019
- Messages
- 2
I'm using a VBA code (that I found and modified by lurking here, kudos!) to create a dynamic index that I then use 15 different Indirect formulas to populate cells with values that create a summary. Basically each cel from B2-P2 is populated with some variation of: =IF(ISBLANK(A2),"",INDIRECT(A2&"!H1"))
I've tried using pivots, but it doesn't get me the formatting that I need, so I've settled on using formulas. Unfortunately, this means that whenever a sheet is added, I then need to manually copy the formula from the above cel by hand. Any suggestions on how to further automate the process? Perhaps something that says if row # = >2 and row = B-P then copy formula from cel above it? I feel like I'm circling the answer but now quite expressing it correctly.
For reference, here is how I am creating the index in the first place. It grabs all the worksheet names except two specifically named ones and anything else I hide and then populates those names in Cels A2 onward.
I've tried using pivots, but it doesn't get me the formatting that I need, so I've settled on using formulas. Unfortunately, this means that whenever a sheet is added, I then need to manually copy the formula from the above cel by hand. Any suggestions on how to further automate the process? Perhaps something that says if row # = >2 and row = B-P then copy formula from cel above it? I feel like I'm circling the answer but now quite expressing it correctly.
For reference, here is how I am creating the index in the first place. It grabs all the worksheet names except two specifically named ones and anything else I hide and then populates those names in Cels A2 onward.
Code:
Private Sub Worksheet_Activate()
Dim wSheet As Worksheet
Dim n As Integer
Dim calcState As Long, scrUpdateState As Long
calcState = Application.Calculation
Application.Calculation = xlCalculationManual
scrUpdateState = Application.ScreenUpdating
Application.ScreenUpdating = False
n = 1
With Me
.Columns(1).ClearContents
.Cells(1, 1) = "Inv #"
.Cells(1, 1).Name = "Index"
End With
For Each wSheet In Worksheets
If wSheet.Name <> Me.Name And wSheet.Name <> "100000" And wSheet.Name <> "999999" And wSheet.Visible = xlSheetVisible Then
n = n + 1
With wSheet
.Range("O1").Name = "Start_" & wSheet.Index
.Hyperlinks.Add anchor:=.Range("O1"), Address:="", _
SubAddress:="Index", TextToDisplay:="Back to Index"
End With
Me.Hyperlinks.Add anchor:=Me.Cells(n, 1), Address:="", _
SubAddress:="Start_" & wSheet.Index, TextToDisplay:=wSheet.Name
End If
Next wSheet
Application.Calculation = calcState
Application.ScreenUpdating = scrUpdateState
End Sub