+ Reply to Thread
Results 1 to 2 of 2

I hijacked a thread

  1. #1
    Registered User
    Join Date
    11-21-2010
    Location
    souh africa
    MS-Off Ver
    Excel 2003
    Posts
    1

    I hijacked a thread

    Please I want a better vba macro that can do the same job as the one below however the one below is extremely slow. thank you

    Sub EARNINGSEQUENCING()
    For i = 38 To 665
    For j = 3 To 9986
    If Worksheets("EARNINGSEQ").Cells(i, 4) = 1991 And _
    Worksheets("EARNINGSEQ").Cells(i, 4) = Worksheets("Sheet1").Cells(j, 16) And _
    Worksheets("EARNINGSEQ").Cells(i, 7) = Worksheets("Sheet1").Cells(j, 3) And _
    Worksheets("EARNINGSEQ").Cells(i, 8) = Worksheets("Sheet1").Cells(j, 17) Then
    Worksheets("EARNINGSEQ").Cells(i, 10) = Worksheets("Sheet1").Cells(j, 14)
    Worksheets("EARNINGSEQ").Cells(i, 11) = Worksheets("Sheet1").Cells(j + 1, 14)
    Worksheets("EARNINGSEQ").Cells(i, 12) = Worksheets("Sheet1").Cells(j + 2, 14)
    Worksheets("EARNINGSEQ").Cells(i, 13) = Worksheets("Sheet1").Cells(j + 3, 14)
    End If
    If Worksheets("EARNINGSEQ").Cells(i, 4) = 1992 And _
    Worksheets("EARNINGSEQ").Cells(i, 4) = Worksheets("Sheet1").Cells(j, 16) And _
    Worksheets("EARNINGSEQ").Cells(i, 7) = Worksheets("Sheet1").Cells(j, 3) And _
    Worksheets("EARNINGSEQ").Cells(i, 8) = Worksheets("Sheet1").Cells(j, 17) Then
    Worksheets("EARNINGSEQ").Cells(i, 10) = Worksheets("Sheet1").Cells(j, 14)
    Worksheets("EARNINGSEQ").Cells(i, 11) = Worksheets("Sheet1").Cells(j + 1, 14)
    Worksheets("EARNINGSEQ").Cells(i, 12) = Worksheets("Sheet1").Cells(j + 2, 14)
    Worksheets("EARNINGSEQ").Cells(i, 13) = Worksheets("Sheet1").Cells(j + 3, 14)
    End If
    If Worksheets("EARNINGSEQ").Cells(i, 4) = 1993 And _
    Worksheets("EARNINGSEQ").Cells(i, 4) = Worksheets("Sheet1").Cells(j, 16) And _
    Worksheets("EARNINGSEQ").Cells(i, 7) = Worksheets("Sheet1").Cells(j, 3) And _
    Worksheets("EARNINGSEQ").Cells(i, 8) = Worksheets("Sheet1").Cells(j, 17) Then
    Worksheets("EARNINGSEQ").Cells(i, 10) = Worksheets("Sheet1").Cells(j, 14)
    Worksheets("EARNINGSEQ").Cells(i, 11) = Worksheets("Sheet1").Cells(j + 1, 14)
    Worksheets("EARNINGSEQ").Cells(i, 12) = Worksheets("Sheet1").Cells(j + 2, 14)
    Worksheets("EARNINGSEQ").Cells(i, 13) = Worksheets("Sheet1").Cells(j + 3, 14)
    End If
    If Worksheets("EARNINGSEQ").Cells(i, 4) = 1994 And _
    Worksheets("EARNINGSEQ").Cells(i, 4) = Worksheets("Sheet1").Cells(j, 16) And _
    Worksheets("EARNINGSEQ").Cells(i, 7) = Worksheets("Sheet1").Cells(j, 3) And _
    Worksheets("EARNINGSEQ").Cells(i, 8) = Worksheets("Sheet1").Cells(j, 17) Then
    Worksheets("EARNINGSEQ").Cells(i, 10) = Worksheets("Sheet1").Cells(j, 14)
    Worksheets("EARNINGSEQ").Cells(i, 11) = Worksheets("Sheet1").Cells(j + 1, 14)
    Worksheets("EARNINGSEQ").Cells(i, 12) = Worksheets("Sheet1").Cells(j + 2, 14)
    Worksheets("EARNINGSEQ").Cells(i, 13) = Worksheets("Sheet1").Cells(j + 3, 14)
    End If
    If Worksheets("EARNINGSEQ").Cells(i, 4) = 1995 And _
    Worksheets("EARNINGSEQ").Cells(i, 4) = Worksheets("Sheet1").Cells(j, 16) And _
    Worksheets("EARNINGSEQ").Cells(i, 7) = Worksheets("Sheet1").Cells(j, 3) And _
    Worksheets("EARNINGSEQ").Cells(i, 8) = Worksheets("Sheet1").Cells(j, 17) Then
    Worksheets("EARNINGSEQ").Cells(i, 10) = Worksheets("Sheet1").Cells(j, 14)
    Worksheets("EARNINGSEQ").Cells(i, 11) = Worksheets("Sheet1").Cells(j + 1, 14)
    Worksheets("EARNINGSEQ").Cells(i, 12) = Worksheets("Sheet1").Cells(j + 2, 14)
    Worksheets("EARNINGSEQ").Cells(i, 13) = Worksheets("Sheet1").Cells(j + 3, 14)
    End If
    Next j
    Next i
    End Sub

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: I hijacked a thread

    Your post does not comply with Rule 2 of our Forum RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread.

    I've moved this thread to a new one since it's your first post.

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here.

+ 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