Unable to set ColumnWidth property

D

DaveL

The VBA code I'm having trouble with follows:
Set Day_CalColHdr = Range(Data.Cells(1, ColC + 1), Data.Cells(4, ColC2))
Day_CalColHdr.ColumnWidth = 2.5
The commands work fine with custom view zoom set at 85% but when I set it to
25% so I cans see it executing I get a 1004 run time error and the following
error:"Unable to set the ColumnWidth property of the range class." Why does
this happen?
 
J

JLGWhiz

can't duplicate the error. Tried it with expansion and contraction and it
works both ways at 25% for a rectangular range of 24 cells over 3 columns. I
thought it might be a screen resolution problem but that does not seem to be
the case, at least on my system, but I am running wide screen.
 
D

DaveL

Thanks for trying to help and going through so much trouble.

Last night we switched from Excel 2003 to excel 2007 and when I ran my macro
again this morning it worked fine in excel 2007. Just so you know, I ran
this same macro in Excel 2003 more than a dozen tmes and it always fails but
only when i zoom out to 25% vice 85%. However, I will have to deal with
people still working in 2003 and I still would like to know what is causing
this. So, let me add some details that were not in my original email and ask
only for some leads an not all the work you did before.

I'm working in a workbook that builds calendars (first 41 columns are data
and last 100+ are columns calendar information). My macro builds other
calendars in other worksheets by swapping out the calendar header information
(i.e. one calendar sequences by month of the year and the next is more
detailed by day of the month). When I start the macro at zoom 85% for the
window it works fine, but when I zoom to 25%, so I can watch it, and then
start my macro all my calendars build as before in separte worksheets except
the last one where the program resizes the columns of the calendar from
standard 8.43 to 2.5 and that's when the error occurs. Doesn't occur in
Excell 2007 though. Just any thoughts on how to recode this to be more
robust and not run into problems when someone with excel 2003 runs this would
be helpful.
 
J

JLGWhiz

Since I am running Excel 2003 and cannot duplicate the error, I am afraid I
can't offer any suggestions.
 

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