0

I am trying to figure out how to add a theme to my excel worksheet before saving it. I have found this code to change the cell color but have yet to find anything to change to a pre-default excel table format (the Table style light 2 theme)

    With xlSheet.Range("A:D").Interior
        .Pattern = Excel.XlPattern.xlPatternLinearGradient
        .Gradient.Degree = 60
        .Gradient.ColorStops.Clear()

        With .Gradient.ColorStops.Add(0)
            .ThemeColor = Excel.XlThemeColor.xlThemeColorAccent1
            .TintAndShade = 0
        End With
    End With

How can i just select all the cells and place that Table style light 2 onto them all using VB.net?

Any help would be great! Thanks! :o)

David

2 Answers 2

1

Try

Selection.Style = "Style name"
Sign up to request clarification or add additional context in comments.

Comments

0

I got it by using the following:

xlSheet.Range("Table1[#All]").Select()
xlSheet.ListObjects("Table1").TableStyle = "TableStyleLight2"

David

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.