I have picked up two different types of code to hide columns through searching this site. However neither are working the way I am tring to use them... Here is a sample of my code. (i realize both lines are attempting the same thing.. I have been commenting out one line to try the other.
Now if I change them to this they work... I just figure there has to be a better way.
I understand why the range example is not working because "D" is not a range.. The prefered answer would be to use the Columns("D").Hidden = True method but is there a way to include all of the columns in a single line?
Code:
Set ssht = Workbooks("Account Lookup Table - Dept ROF File Output").Sheets("ROF Col")
Set dsht = Workbooks("Collections - Central").Sheets("Feb 09")
With dsht
.Unprotect Password:=""
Columns("D,G,H,L,O,P,T,W,X,AB,AE,AD,AV,AM,AN,AR,AU,AV").Hidden = True
Range("D,G,H,L,O,P,T,W,X,AB,AE,AD,AV,AM,AN,AR,AU,AV").EntireColumn.Hidden = True
Now if I change them to this they work... I just figure there has to be a better way.
Code:
Set ssht = Workbooks("Account Lookup Table - Dept ROF File Output").Sheets("ROF Col")
Set dsht = Workbooks("Collections - Central").Sheets("Feb 09")
With dsht
.Unprotect Password:=""
Columns("D").Hidden = True
Columns("G").Hidden = True
Columns("H").Hidden = True
'and so on
'or
Range("D:D,G:H,L:L,O:P,T:T, and so on").EntireColumn.Hidden = True
I understand why the range example is not working because "D" is not a range.. The prefered answer would be to use the Columns("D").Hidden = True method but is there a way to include all of the columns in a single line?