ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Unable to set ColumnWidth property (https://www.excelbanter.com/excel-programming/416808-unable-set-columnwidth-property.html)

DaveL

Unable to set ColumnWidth property
 
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?


JLGWhiz

Unable to set ColumnWidth property
 
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.

"DaveL" wrote:

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?


DaveL

Column Width error
 
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.

"JLGWhiz" wrote:

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.

"DaveL" wrote:

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?


JLGWhiz

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

"DaveL" wrote:

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.

"JLGWhiz" wrote:

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.

"DaveL" wrote:

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?



All times are GMT +1. The time now is 11:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com