B
Bart
Dear all,
Adding Column Widths is somehow a very inaccurate matter. I tried to
measure the Width of 5 columns and make an other Column as wide as the
Widths of these 5 columns together. The column appeared to be less
wide.
It seems that the measurements aren't linear. Though I found out that
there's a relation between Characters and Pixels (Characters with the
Standard Font and Size).
m1 (Characters) | m2 (Pixels)
1 12
5 40
10 75
20 145
50 355
100 705
P = 7 * C + 5
P = number of Pixels
C = number of Characters
For example in my case I found the following measurements in
Characters (and Pixels):
2.86 (25 Pixels) +
15.86 (116 Pixels) +
15.86 (116 Pixels) +
15.86 (116 Pixels) +
12.29 (91 Pixels) +
20.14 (146 Pixels)
=82.87 Characters
The sum of these round figures is 82.87 Characters. (They are round
figures as they are when I read them as a Property of a Column.)
The sum of Pixels (not round figures) is 610.
Since the values of the ColumnWidth are round figures the calculation
isn't accurate (and so you might say non-linear). Calculating the
number of Characters with the number of Pixels by using the formula
stated above you get:
610 Pixels ≡ 86.43 Characters,
and not 82.87 Characters as stated above.
To work around this problem is by calculating in Pixels instead of
Characters. First convert the ColumnWidths to Pixels, do the
calculation and then convert it back to Characters. Like this e.g.:
Dim intPixels As Integer
Dim intTotalColumnWidth As Integer
Dim sngTotalColumnWidth As Single
For i = 1 To 3
intPixels = CInt(myRange.Columns(i).ColumnWidth * 7! + 5!)
intTotalColumnWidth = intTotalColumnWidth + intPixels
Next i
sngTotalColumnWidth = CSng(intTotalColumnWidth - 5) / 7!
myRange.Columns(1).ColumnWidth = sngTotalColumnWidth
Does someone have any other suggestions to obtain the ColumnWidth in
Pixels or calculate with ColumnWidths?
Bart
Adding Column Widths is somehow a very inaccurate matter. I tried to
measure the Width of 5 columns and make an other Column as wide as the
Widths of these 5 columns together. The column appeared to be less
wide.
It seems that the measurements aren't linear. Though I found out that
there's a relation between Characters and Pixels (Characters with the
Standard Font and Size).
m1 (Characters) | m2 (Pixels)
1 12
5 40
10 75
20 145
50 355
100 705
P = 7 * C + 5
P = number of Pixels
C = number of Characters
For example in my case I found the following measurements in
Characters (and Pixels):
2.86 (25 Pixels) +
15.86 (116 Pixels) +
15.86 (116 Pixels) +
15.86 (116 Pixels) +
12.29 (91 Pixels) +
20.14 (146 Pixels)
=82.87 Characters
The sum of these round figures is 82.87 Characters. (They are round
figures as they are when I read them as a Property of a Column.)
The sum of Pixels (not round figures) is 610.
Since the values of the ColumnWidth are round figures the calculation
isn't accurate (and so you might say non-linear). Calculating the
number of Characters with the number of Pixels by using the formula
stated above you get:
610 Pixels ≡ 86.43 Characters,
and not 82.87 Characters as stated above.
To work around this problem is by calculating in Pixels instead of
Characters. First convert the ColumnWidths to Pixels, do the
calculation and then convert it back to Characters. Like this e.g.:
Dim intPixels As Integer
Dim intTotalColumnWidth As Integer
Dim sngTotalColumnWidth As Single
For i = 1 To 3
intPixels = CInt(myRange.Columns(i).ColumnWidth * 7! + 5!)
intTotalColumnWidth = intTotalColumnWidth + intPixels
Next i
sngTotalColumnWidth = CSng(intTotalColumnWidth - 5) / 7!
myRange.Columns(1).ColumnWidth = sngTotalColumnWidth
Does someone have any other suggestions to obtain the ColumnWidth in
Pixels or calculate with ColumnWidths?
Bart