Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
columns width in a single vba statement
Whats wrong with that?
Columns("A:E").Width = Application.Array(5, 10, 5, 10, 5) Thanks in advance |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
columns width in a single vba statement
Whats wrong with that?
Columns("A:E").Width = Application.Array(5, 10, 5, 10, 5) Thanks in advance 2 things I see right of are.. The Application object does not support an *Array* property (or method); Ranges do not have a *Width* property. Instead, they support *ColumnWidth* and so your statement should read... Columns("A:E").ColumnWidth = Array(5, 10, 5, 10, 5) ...but this is very slow to process (took about 1.5 minutes on my machine) as a single statement. This will work orders of magnitude faster (instantaneous) ... Sub SetColWidths() Dim vWidths, n&, j& vWidths = Array(5, 10, 5, 10, 5) With Range("A:E") For n = 1 To .Columns.Count .Columns(n).ColumnWidth = vWidths(j): j = j + 1 Next 'n End With 'Range("A:E") End Sub -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
columns width in a single vba statement
On Monday, January 13, 2014 12:04:09 PM UTC-2, Fcoatis wrote:
Whats wrong with that? Columns("A:E").Width = Application.Array(5, 10, 5, 10, 5) Thanks in advance Thanks GS for the notes. Best Regards |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
columns width in a single vba statement
On Monday, January 13, 2014 12:04:09 PM UTC-2, Fcoatis wrote:
Whats wrong with that? Columns("A:E").Width = Application.Array(5, 10, 5, 10, 5) Thanks in advance Thanks GS for the notes. Best Regards You're welcome! -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
adjust width of single cell in Excel | Charts and Charting in Excel | |||
Set Column Width Based On Total Width Of Other Columns | Excel Programming | |||
How to change single cell width | Excel Worksheet Functions | |||
How to change a single cell's width | Excel Worksheet Functions |