+ Reply to Thread
Results 1 to 3 of 3

Clean up and Fix Two Macros

  1. #1
    Registered User
    Join Date
    03-17-2004
    Posts
    28

    Clean up and Fix Two Macros

    I’ve got two macros. One loops to see if any cells in a range match another cell. If so then it goes to another macro. My problem is, it stops there. I need this to continue running until there are no more matches.

    For example, macro1 looks at two ranges, if there is a match it immediately cuts to macro2. Macro2 does some copying and pasting and stuff, then stops. How can I get them to continue?

    Below is the code (I know it’s sloppy, I’m new to this). Any help is appreciated. By the way, these do not necessarily need to be two separate macros, that’s just the way I initially put it down.

    Sub macro1()
    'moves data from Data Entry (sheet1) to Summary (sheet5)
    Application.ScreenUpdating = False
    Sheet1.Select
    Range("A1").Select

    Do

    If ActiveCell.Value = Sheet5.Range("b1").Value Then

    ActiveCell.EntireRow.Copy

    PasteOnsheet5

    ActiveCell.Offset(1, 0).Select
    Else

    End If
    ActiveCell.Offset(1, 0).Select
    Loop Until IsEmpty(ActiveCell) = True

    Application.ScreenUpdating = True
    End Sub

    Sub PasteOnsheet5()
    Application.ScreenUpdating = False
    Sheet5.Select
    Range("A5").Select

    Do

    If IsEmpty(ActiveCell) = False Then

    ActiveCell.Offset(1, 0).Select

    End If

    Loop Until IsEmpty(ActiveCell) = True
    ActiveSheet.Paste
    Application.ScreenUpdating = True
    End Sub

  2. #2
    Registered User
    Join Date
    01-20-2006
    Posts
    19

    activesheet

    think you have to go back to sheet1 (correct cell) after you went to sheet5 in PasteOnsheet5

  3. #3
    Registered User
    Join Date
    03-17-2004
    Posts
    28
    Wow, I can't believe it was that easy. Thanks a bunch.

+ 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