Avatar of gisvpn
Flag for United States of America asked on

Problems selecting Columns and formatting


I am working in Excel 2010 and I have problems referencing where I want to format.

    With Selection.Interior
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorDark1
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With

I have the above code but find it really difficult to select this place and it is with mainly this statement Columns("B:B").Select.

I try and many varients like it


but it does not like this at all and I get it to work.

Can someone please tell me the correct way to reference an area to then format it or do something with it?


Microsoft Excel

Avatar of undefined
Last Comment
Ingeborg Hawighorst (Microsoft MVP / EE MVE)

8/22/2022 - Mon
Ingeborg Hawighorst (Microsoft MVP / EE MVE)

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Hey thanks for the post. Can I use this to manipulate code and set values and embed if statement in also ?  


Ingeborg Hawighorst (Microsoft MVP / EE MVE)

Glad this answered you question.

What do you mean by "manipulate code"? And yes, VBA supports IF statements, too.

You should start new questions for each of these issues.

cheers, teylyn

Hey Teylyn,

It was just to check I could use this method to reference a column or specific cell which I think it does ;)


I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck
Ingeborg Hawighorst (Microsoft MVP / EE MVE)

Well, yes. The code above references column B in a With statement. In the same manner, you can reference other ranges.