ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Resising Columns in vb code. (https://www.excelbanter.com/excel-programming/357015-resising-columns-vbulletin-code.html)

Camper Joe

Resising Columns in vb code.
 
Hi.

I am trying to resize my columns in Excel through VB6.

I have created my excel.appliation object (xl) and created a new workbook.
Now I want to use the code:

xl.Cells(1, 1).Width = 100, but I get: Unable to set the width property of
the Range class.

Even when I try
xl.Columns(2).Width = 100

I get the same error.


[email protected]

Resising Columns in vb code.
 
What about:

xl.Columns("A:A").ColumnWidth = 100

(any range) in place of A:A


Stefi

Resising Columns in vb code.
 
Try
ActiveWorkbook.ActiveSheet.Columns("B:B").ColumnWi dth = 100

You can replace ActiveWorkbook and ActiveSheet with other valid WB and WS
references if necessary.

Regards,
Stefi


€˛Camper Joe€¯ ezt Ć*rta:

Hi.

I am trying to resize my columns in Excel through VB6.

I have created my excel.appliation object (xl) and created a new workbook.
Now I want to use the code:

xl.Cells(1, 1).Width = 100, but I get: Unable to set the width property of
the Range class.

Even when I try
xl.Columns(2).Width = 100

I get the same error.



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

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