Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I have a routine that pastes an array to a worksheet. I want to have it call another routine that autosizes all the columns at once, then if any column widths excede my max, it sets width to max. Everthing comes to an "Error 13" Wrong Type crash at this line: Set cols = pasteRange .Columns I'm not sure if I'm defining the variable wrong or what. Any help would be great, Thanks, MikeZz Private Sub z20_Set_This_Range_from_Array(rng1Cell As Range, arr() As Variant, Optional autoFitCols as Boolean) Dim r, c Dim cols As Columns Dim pasteRange As Range r = UBound(arr, 1) - LBound(arr, 1) c = UBound(arr, 2) - LBound(arr, 2) Set pasteRange = Range(rng1Cell, rng1Cell.Offset(r, c)) pasteRange = arr If IsMissing(autoFitCols) Then Else Set cols = pasteRange .Columns If autoFitCols = True Then _ Call z30_Set_Auto_Column_Size_With_Max(cols, 25) Set cols = Nothing End If End Sub Sub z30_Set_Auto_Column_Size_With_Max(cols As Columns, cMax) Dim col As Column cols.AutoFit For Each col In cols If col.Width cMax Then col.Width = cMax Next col End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Subject: Type 13 Error when defining a Columns variable | Excel Programming | |||
Defining Variable Type for Items and Keys in Dictionary | Excel Programming | |||
Defining a type of the cell | Excel Programming | |||
Defining the subject of an Email by value in range | Excel Programming | |||
Defining input box data type? | Excel Programming |