+ Reply to Thread
Results 1 to 3 of 3

Too slow and excel stops responding

Hybrid View

  1. #1
    Registered User
    Join Date
    05-15-2012
    Location
    Chennai
    MS-Off Ver
    Excel 2003
    Posts
    2

    Too slow and excel stops responding

    Hello,
    I have a sub routine in which i use two loops. I dont know how to increase the effectiveness of the code. I just want the code to run successfully.
    Please Help!!

    The arrays are globally initialized.


    Sub printtsales()
    Excel.Application.Calculation = xlCalculationManual

    Dim j, k As Integer
    j = 1
    k = 1

    While k <= 276
    While j <= 53
    If Not IsEmpty(salesqtya(j, k)) Or Not salesqtya(j, k) = 0 Then
    Sheets("Sales").Cells(3 + k, 1 + j).Value = salesqtya(j, k)
    End If
    If Not IsEmpty(salesvala(j, k)) Or Not salesvala(j, k) = 0 Then
    Sheets("Sales").Cells(280 + k, 1 + j).Value = salesvala(j, k)
    End If
    If Not IsEmpty(salesqtyp(j, k)) Or Not salesqtyp(j, k) = 0 Then
    Sheets("SalesP").Cells(3 + k, 1 + j).Value = salesqtyp(j, k)
    End If
    If Not IsEmpty(salesvalp(j, k)) Or Not salesvalp(j, k) = 0 Then
    Sheets("SalesP").Cells(280 + k, 1 + j).Value = salesvalp(j, k)
    End If
    j = j + 1
    Wend
    j = 1
    k = k + 1
    Wend
    Excel.Application.Calculation = xlCalculationAutomatic

    End Sub

  2. #2
    Registered User
    Join Date
    05-15-2012
    Location
    Chennai
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Too slow and excel stops responding

    [QUOTE=Ushzz;2789964]Hello,
    I have a sub routine in which i use two loops. I dont know how to increase the effectiveness of the code. I just want the code to run successfully.
    Please Help!!

    The arrays are globally initialized.


    Sub printtsales()
    Excel.Application.Calculation = xlCalculationManual

    Dim j, k As Integer
    j = 1
    k = 1

    While k <= 276
    While j <= 53
    If Not IsEmpty(salesqtya(j, k)) Or Not salesqtya(j, k) = 0 Then
    Sheets("Sales").Cells(3 + k, 1 + j).Value = salesqtya(j, k)
    End If
    If Not IsEmpty(salesvala(j, k)) Or Not salesvala(j, k) = 0 Then
    Sheets("Sales").Cells(280 + k, 1 + j).Value = salesvala(j, k)
    End If
    If Not IsEmpty(salesqtyp(j, k)) Or Not salesqtyp(j, k) = 0 Then
    Sheets("SalesP").Cells(3 + k, 1 + j).Value = salesqtyp(j, k)
    End If
    If Not IsEmpty(salesvalp(j, k)) Or Not salesvalp(j, k) = 0 Then
    Sheets("SalesP").Cells(280 + k, 1 + j).Value = salesvalp(j, k)
    End If
    j = j + 1
    Wend
    j = 1
    k = k + 1
    Wend
    Excel.Application.Calculation = xlCalculationAutomatic

    End Sub


    Please help!

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Too slow and excel stops responding

    Please add code tags to your posts
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1