Results 1 to 5 of 5

Thread: [RESOLVED] Excel2007 -Issues with Large Select Case Row height & 200 NonContiguous Ranges

Hybrid View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    222

    Re: [RESOLVED] Excel2007 - Issues with a large Non-Contiguous range & a large Select

    HI again westconn1,

    I modified and tested the code using only Row and col, as you suggested and that worked well. ---Thanks---
    For Row = 1 To 432
    myRows = .Cells(Row, 1).Row<- Removed
    Select Case Row<-Changed from: myRows to: Row in this command

    For col = 1 To 26
    myCols = .Cells(1, col).Column<- Removed
    Select Case col<-Changed from: myCols to: col in this command

    To improve that part of the code even further though,
    I decided that because "Row" might technically be thought of as a keyword, it's best to avoid it...So I changed Row to: intRow
    and to be consistent I also changed col to: intCol

    Before you gave me your excellent tips, the revisions I had made and posted, did already solve my speed issue.
    - The further developed code that uses some of your recommendations did not speed things up noticeably,
    I would need to use a timer to know, as it already is running in under 1/2 of a second

    I decided not to adopt your recommendation to combine cases, because I occasionally make code edits to some of the Row height's,
    and some times those that had been the same height, may later become different..
    (Also for me, because now that i have expanded it to 432 Row Cases, I see it as quicker to visually locate the Case Row in the code, if i do not have them combined.)

    As far as what had originally been causing the code to run so slow, perhaps that may have been my use of Range("A1").Offset(Row, 1) , where now I am using .Cells(Row, 1)

    If not that, then maybe I had a typo in my original code, that I inadvertently later corrected.

    Either way, thanks for your help.

    Improved code sample
    Code:
    Dim intCol As Integer, intRow As Integer
    'Dim myRows As Double, mycol As Double<-Discontinued the use of these two variables
    
    With ActiveSheet
    
         .EnableCalculation = False
    
         Application.ScreenUpdating = False
    
    For intRow = 1 To 432
     
    Select Case intRow
    
    Case 1
        .Cells(intRow, 1).RowHeight = 45.75
    Case 2
        .Cells(intRow, 1).RowHeight = 96
    Case 3
        .Cells(intRow, 1).RowHeight = 19.5
    'and so on -----------------------
    Case 432
        .Cells(intRow, 1).RowHeight = 3
    End Select
    
    Next
    
    For intCol = 1 To 26
        
    Select Case intCol
    
    Case 1
        .Cells(1, intCol).ColumnWidth = 8.57
    Case 2
        .Cells(1, intCol).ColumnWidth = 8
    Case 3
        .Cells(1, intCol).ColumnWidth = 29.57
    'and so on -----------------------
    Case 12
        .Cells(1, intCol).ColumnWidth = 1.14
    Case Else
        .Cells(1, intCol).ColumnWidth = 8.43
    
    End Select
    
    Next
    
         .EnableCalculation = True
    
    End With
    
         Application.ScreenUpdating = True
    Last edited by SQLADOman; Aug 1st, 2010 at 12:22 PM. Reason: Decided the code is easier to read using intCol and intRow, instead of col & Row(as Row is technically a keyword)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width