Results 1 to 12 of 12

Thread: [RESOLVED] Excel VBA - alternatives for loops?

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2006
    Posts
    96

    Resolved [RESOLVED] Excel VBA - alternatives for loops?

    Hi guys

    I just found out that one of my old macro's didn't do its job well enough. So I rewrote it - unfortunately I'm not that gifted at VBA, so now I need to charge the computer with a supernova if it should be able to process it!

    I found I need a total of 5 nested for...next statements with the following counters:
    VB Code:
    1. For i = 5 To 250
    2.     For j = i To i + 15
    3.         For k = i To i + 15
    4.             For l = 5 To 250
    5.                 For m = l To l + 15
    6.                     If gSheet.Cells(i, 1).Value = "BFORR" Then
    7.                         If gSheet.Cells(j, 2).Value = "Kundegrupper" Then
    8.                             gSheet.Activate
    9.                             gSheet.Rows(j).EntireRow.Copy
    10.                             tSheet.Activate
    11.                             tSheet.Rows(j).PasteSpecial

    The code goes on like this, eventually to include k,l and m as well.

    As I said - it takes literally ages (Don't know how long to be precise, but so far +3hours - I can do it manually in 1!)

    Is there an alternative to for...next or can I make it leaner in a way??

    /Nick
    Last edited by direktoren; May 17th, 2006 at 09:28 AM. Reason: RESOLVED

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