I am trying to write a VBA function where I produce a new sheet, give a lists of all the sheet names in the workbook and match the cell color of the sheet name, with the tab color of the sheet name. The pseudocode will look something like this:
Create a new sheet Loop through all sheets in the workbook Write down the sheet name in the created sheet Retrieve the sheet ThemeColor (e.g. xlThemeColorLight2) Retrieve the sheet TintAndShade (e.g. 0.799981688894314 Set the cell in which the name of the sheet is to the correct ThemeColor and TintAndShade End
Is there a way in which this is possible?
Sub SheetList()
Dim ws As Worksheet
Dim x As Integer
x = 1
Sheets.Add
sheet_name = InputBox("Please enter a sheet name")
ActiveSheet.Name = sheet_name # Create a new sheet name
For Each ws In Worksheets
Sheets(sheet_name).Cells(x, 1) = ws.Name # Set cell value to sheet name
Dim theme_color As String
Dim tint_and_shade As Single
theme_color = ... # Attain sheet ThemeColor of current ws here
tint_and_shade = ... # Attain sheet TintAndShade of current ws here
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.ThemeColor = theme_color # Set current cell to theme_color
.TintAndShade = tint_and_shade # Set current cell to tint_and_shade
.PatternTintAndShade = 0
End With
x = x + 1
Next ws