LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 87
Default Setting Column Widths

I have a spreadsheet which has been created on another computer, and I am
having problems setting the column widths. My version of Excel 2003 is set to
use a default font size of 10. It appears that the computer the sheet was
created on, had a default font size of 12, because if I manually set the
column width to 10 and type in "1234567890" with a font size of 12 it fills
the column.

Having searched this forum I found a contribution from Nick HK and tried the
following code. On one of my spread sheets it worked fine - the message
returned 161.25, 161.25, 1.
When I ran it on the imported file it produced 207.75, 162.75, 1.27.
It has set the column width to 162.75 rather than the 161.25 I was expecting.
Is it possible to get it to set exactly? If not what margin of error can I
expect? In this example it is quite small but with some other code I was
getting 40.5 (aim) and 42 (actual) when using a factor derived from the
widest column (71.25) as the factor for a narrower column.

Sub test()
With Worksheets(1)
.Cells(5, 1).ColumnWidth = 30
Wpxl1 = .Columns(1).Width
factor = 161.25 / Wpxl1
.Cells(5, 1).ColumnWidth = 30 * factor
Wpxl2 = .Columns(1).Width
MsgBox Wpxl1 & ", " & Wpxl2 & ", " & Wpxl1 / Wpxl2
End With
End Sub

 
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
Different widths for each column in a 100% stacked column chart Chart Explorer Charts and Charting in Excel 1 May 21st 09 09:19 AM
Setting column widths the same on multiple worksheets John Excel Discussion (Misc queries) 2 April 19th 08 04:00 PM
Setting column widths when mapping out a field trial. Candys Kisses Excel Worksheet Functions 1 August 21st 07 12:12 AM
Setting tab widths kirkm[_6_] Excel Programming 0 March 13th 07 05:19 AM
Auto setting column widths accross a whole workbook vMaster Excel Programming 3 December 26th 05 12:55 PM


All times are GMT +1. The time now is 07:40 PM.

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

About Us

"It's about Microsoft Excel"