Avatar of gisvpn
gisvpn
Flag for United States of America asked on

Problems selecting Columns and formatting

Hi,

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

Columns("B:B").Select
    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

sheets("xxx").Columns("B:B").Select

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?

Thanks,

GISVPN
Microsoft Excel

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

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
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
or
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
gisvpn

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

Thanks

Gisvpn
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
gisvpn

ASKER
Hey Teylyn,

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

Thanks,

GISVPn
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.