View Single Post
  #27   Report Post  
Posted to microsoft.public.excel.programming
Howard Kaikow Howard Kaikow is offline
external usenet poster
 
Posts: 269
Default RowHeight and AutoFit wit Merged Cells

"Peter T" <peter_t@discussions wrote in message
...
Address limit is 255 in '97 to 2003, up to 16 areas anywhere on the sheet.


The limit is not 16 areas, I am currently using 25.

Also, the address limit is higher in Excel 97 than in Excel 2003, see code
below.
I ran the code in both 97 and 2003.

I have to dynamically create the string, so I can use On Error to see
whether I have to process in chunks. Code below adds 4 areas at a time. I
will refine to get accurate number.

Private Sub AreasString()
Dim count As Long
Dim high As Long
Dim r As Long
Dim i As Long
Dim sArea As String
Dim rng As Excel.Range

Const DescriptorRows As Long = 6
Const PerRow As Long = 4
Const RowNext As Long = 3

On Error Resume Next
For count = 20 To 40
high = Ceil(count / PerRow)
sArea = ""
r = -(DescriptorRows - 1) + RowNext
For i = 1 To high
r = r + DescriptorRows
sArea = sArea + ",A" & r & ":B" & r & ",C" & r & ":D" & r & ",E"
& r & ":F" & r & ",G" & r & ":H" & r
Next i
Set rng = Range(Mid$(sArea, 2))
With Err
If .Number < 0 Then
Debug.Print .Number, .Description
Debug.Print vbTab;
.Clear
End If
End With
Debug.Print count, Len(Mid$(sArea, 2)) - 1, Mid$(sArea, 2)
Next count
On Error GoTo 0
End Sub

Public Function Ceil(dblSource As Double) As Long
Dim dblFloor As Double

dblFloor = Int(dblSource)
If dblFloor = dblSource Then
Ceil = dblFloor
Else
Ceil = dblFloor + 1
End If
End Function