|
-
Jul 31st, 2010, 07:43 PM
#3
Re: [RESOLVED] Excel2007 - Issues with a large Non-Contiguous range & a large Select
you can cut your select cases by using multiple criteria
from you code above
vb Code:
Select Case myCols Case 1 .Cells(1, col).ColumnWidth = 8.57 Case 2, 3 .Cells(1, col).ColumnWidth = 8 'Case 3 ' .Cells(1, col).ColumnWidth = 8 'Continues to case 26 End Select
so you could use like
case 2 to 6, 9 to 13, is >21
you can also use case else for any default value
another option is to set the col width for the entire range first, then only change the cols that are different
select case only evaluates conditions until it finds a match so, for speed, order the cases by the expected most common result (does not apply in this example, as each number is only used once)
also in the above code mycols is always made = to col, so it is not required, you can just select case col
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|