Link to home
Start Free TrialLog in
Avatar of gisvpn
gisvpnFlag 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
ASKER CERTIFIED SOLUTION
Avatar of Ingeborg Hawighorst (Microsoft MVP / EE MVE)
Ingeborg Hawighorst (Microsoft MVP / EE MVE)
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 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
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
Avatar of 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
Well, yes. The code above references column B in a With statement. In the same manner, you can reference other ranges.