View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary Brown Gary Brown is offline
external usenet poster
 
Posts: 178
Default Cannot set ColumnWidth past column 148

Don't know what the issue may be.
Have you debugged to see what the value of 'Endcolumn' is?
Debug.Print Endcolumn
--
HTH,
Gary Brown

If this post was helpful to you, please select ''YES'' at the bottom of the
post.



"MNTye" wrote:


I have a spreadsheet with 198 columns built by VBA procedures. Columns 7
thru 198 contain monthly data, i.e., columns 7 thru 18 contain data for
the months of year 1, columns 19 thru 30 contain data for the months of
year 2, ...., columns 187 thru 198 contain data for the months of year
16.

I need to set the ColumnWidth for columns 7 thru 198 to 4. I've never
had a problem setting ColumnWidth before as I do this (among other
things) for a living for the past 8 months. I've tried multiple
methods, i.e., Range, Range-by-Range, Column-by-Column, and each one
fails at column 149.


Code:
--------------------
Dim col As Integer
.
.
.
Startcolumn = Range(Replace(Replace(Replace(Replace(ActiveSheet. Name, ")", "_"), "(", "_"), " ", "_"), "-", "_") + "endheader").Column
Endcolumn = Range(Replace(Replace(Replace(Replace(ActiveSheet. Name, ")", "_"), "(", "_"), " ", "_"), "-", "_") + "endheader2").Column
col = Startcolumn
While col < Endcolumn
For Each cols In ActiveSheet.Range(Cells(6, col), Cells(6, col))
cols.ColumnWidth = 4
Next cols
col = col + 1
Wend
--------------------


I appreciate any help you can give. Thanks!


--
MNTye
------------------------------------------------------------------------
MNTye's Profile:
http://www.excelforum.com/member.php...o&userid=36058
View this thread: http://www.excelforum.com/showthread...hreadid=558448