Mulipule Columns & VBA

E

Excel 2007 - SPB

I have a series of columns I wish to hide, these change depending on the
report selected
VBA refers to F18 on sheets1 and changes dependent on the report selected
code is;
Sheets(2).Select
Columns("V:AB").Select ' Resets all columns
Selection.EntireColumn.Hidden = False

colhide = sheets(1).range("F18")
Sheets(2).Select
Columns(colhide).Select
Selection.EntireColumn.Hidden = True

This works if the Columns are a continious block ie. F18 = "B;F"
but fails if F18="B:B,F:AA,AC:AC"

Any ideas
 
M

Mike H

Hi,

Try this in F18
V:V,W:W,X:X,Y:Y,Z:Z,AA:AA,AB:AB, AF:AF

and you may find this a little better

Sub ordinate()
colhide = Sheets(1).Range("F18")
Sheets(2).Select
Range(colhide).EntireColumn.Hidden = True
End Sub

Mike
 
E

Excel 2007 - SPB

Works Great

Thanks I knew it would be simple

Mike H said:
Hi,

Try this in F18
V:V,W:W,X:X,Y:Y,Z:Z,AA:AA,AB:AB, AF:AF

and you may find this a little better

Sub ordinate()
colhide = Sheets(1).Range("F18")
Sheets(2).Select
Range(colhide).EntireColumn.Hidden = True
End Sub

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top