I have a dashboard page with a bunch of totals on it and I'm creating this event code so that it gives specific detail of that item when it is double-clicked. I didn't want to do this via pivot tables because the pivots display too much unnecessary data when drilling down so i basically made a page that links to all my pivots and I'm improvising.
However, to save space on this workbook, I think it would be most practical if everytime someone double-clicked it creates the sheet as new, and then fills in the data for the first time with formulas so that i don't have tons of worksheets just hidden with prebuilt formulas, making the file huge. With this logic, I was thinking that I would need some kind of delete sheet event code so that each time it's only creating one sheet and the other that was created before be deleted.
Would i do this with select case, and name the sheets that i don't want deleted in this file, and have it delete all the rest? The sheet names i need intact are "MasterList" & "Dashboard". I'm not really sure how to write this code, but i have this thus far:
However, to save space on this workbook, I think it would be most practical if everytime someone double-clicked it creates the sheet as new, and then fills in the data for the first time with formulas so that i don't have tons of worksheets just hidden with prebuilt formulas, making the file huge. With this logic, I was thinking that I would need some kind of delete sheet event code so that each time it's only creating one sheet and the other that was created before be deleted.
Would i do this with select case, and name the sheets that i don't want deleted in this file, and have it delete all the rest? The sheet names i need intact are "MasterList" & "Dashboard". I'm not really sure how to write this code, but i have this thus far:
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Address(False, False) = "C4" Then
Cancel = True
Application.ScreenUpdating = False
Sheets.Add.Name = "SunOp-FGSch"
Sheets("SunOp-FGSch").Activate
Sheets("SunOp-FGSch").Range("A1").FormulaR1C1 = "Materials"
Sheets("SunOp-FGSch").Range("B1").FormulaR1C1 = "Description"
Sheets("SunOp-FGSch").Range("C1").FormulaR1C1 = "FG Scheduled"
Sheets("SunOp-FGSch").Range("A1:C1").Select
With Selection.Font
.ThemeColor = xlThemeColorDark1
.Bold = True
.Name = "Arial"
.Size = 10
End With
With Selection.Interior
.ThemeColor = xlThemeColorLight1
End With
Sheets("SunOp-FGSch").Range("A2:A5000").Formula = "=IF(AND(MasterList!E3=""Sun Optics"", MasterList!T3>0),MasterList!B3,"""")"
Sheets("SunOp-FGSch").Range("A2:A" & lastRow).Sort _
Key1:=Sheets("SunOp-FGSch").Columns("A"), Order:=xlDescending
Application.ScreenUpdating = True
End If