helping to make code a quick

  • hello

    i need help to make this code so faster recently is so slow i appreciate if anybody help

  • It would be easier to help and test possible solutions if you could attach a copy of your file. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary).

    You can say "THANK YOU" for help received by clicking the "Like" icon in the bottom right corner of the helper's post.
    Practice makes perfect. I am very far from perfect so I'm still practising.

  • This code is the obvious way to speed it up.


    Code
    For lngMyRow = lngStartRow To lngLastRow
    For lngLoop = 1 To wsInput.Range("L" & lngMyRow)
    wsInput.Range("A" & lngMyRow & ":M" & lngMyRow).Copy Destination:=wsOutput.Range("B" & lngPasteRow)
    wsOutput.Range("A" & lngPasteRow).Value2 = lngLoop
    wsOutput.Range("N" & lngPasteRow).Value2 = Evaluate("G" & lngPasteRow) + lngLoop
    lngPasteRow = lngPasteRow + 1
    Next lngLoop
    lngPasteRow = lngPasteRow + 2
    Next lngMyRow

    Why are you copying and pasting by rows? I'm not even sure what it is supposed to do.

  • sorry i though you changed some thing actually i copy and past without see the changes my code it depends divide my data into many rows based on specific columns

  • Hi alhagag,


    Would I be correct in saying that your code is supposed to loop through each row on Sheet1 and create as many rows as the value in column L and then have the Date column "N" on sheet2 be every date between Enter and Exit Date, and column A on Sheet2 be the current count of loop on the value in column L ?

  • Here's my attempt using arrays, output formating isn't great though



Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!