Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
adjust width of single cell in Excel oravsky123 Charts and Charting in Excel 1 August 28th 07 05:49 PM
Set Column Width Based On Total Width Of Other Columns rayneraingoaway Excel Programming 1 June 28th 06 11:10 PM
How to change single cell width TemporarilyConfused Excel Worksheet Functions 1 November 10th 04 08:17 PM
How to change a single cell's width TemporarilyConfused Excel Worksheet Functions 2 November 10th 04 07:36 PM


All times are GMT +1. The time now is 12:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"