Skipping Macro's

  • I have a masterlist in Excel with macro's to pull information from 20 other lists which are identical in format to the master but will contain different information on each (20 different users inputting on diff lines). The lists will have unique names such as P1, P2, etc.


    It is working great. However the only issue I have is that sometimes a user may not have anything to enter so I might be missing a sheet. Is there a way to adjust the macros so that it can skip over a record if it's not present or must I have a "dummy list" opened for any which are missing? Below is a copy of the macro that I'm using if that helps. This is repeated for P1 up through P20.


    Thanks for advance to any help you can give this brain-weary woman!
    Terry


    [vba] 'Sheets("Instructions").Select
    'Range("C9").Select

    'TotRows = ActiveCell.Value
    'TotRows = TotRows + 1
    Sheets("Prop Base").Select
    Range("Q2").Select

    Windows("P1.xls").Activate
    Range("Q2").Select
    'Rows = 2
    Do Until ActiveCell.Value = ""
    If ActiveCell.Value = "y" Then
    Selection.Copy
    Windows("MasterList.xls").Activate
    ActiveCell.Select
    Selection.Paste
    End If
    Windows("MasterList.xls").Activate
    ActiveCell.Offset(1, 0).Range("A1").Select
    Windows("P1.xls").Activate
    ActiveCell.Offset(1, 0).Range("A1").Select
    Loop

    'Windows("P1.xls").Activate
    'Range("Q2").Select
    'Selection.Copy
    'Windows("MasterList.xls").Activate
    'Range("Q2").Select
    'Windows("MasterList.xls").Activate
    End Sub[/vba]

  • Re: Skipping Macro's


    After you've activated a particular list, let VBA count the number of "y" in the relevant range. If that's 0, then skip by using exit sub or exit loop or exit for, whatever is applicable.


    Wigi

    Regards,


    Wigi


    Excel MVP 2011-2014


    For more Excel memes: visit http://www.wimgielis.com ==> English articles ==> Excel memes


    -- Topics without [CODE] tags or a meaningful topic title, will be neglected by me (and probably many others as well) --

Participate now!

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