1. Welcome to Chandoo.org Forums. Short message for you

    Hi Guest,

    Thanks for joining Chandoo.org forums. We are here to make you awesome in Excel. Before you post your first question, please read this short introduction guide. When posting or responding to questions please remember our values at Chandoo.org are: Humility, Passion, Fun, Awesomeness, Simplicity, Sharing Remember that we have people here for whom English is not there first language and we need to allow for this in our dealings.

    Yours,
    Chandoo
  2. Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  3. When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Merge the code

Discussion in 'VBA Macros' started by Abhishek A, Mar 15, 2019 at 10:45 AM.

  1. Abhishek A

    Abhishek A New Member

    Messages:
    25
    Hi,

    I have 3 codes below.. Can you please merge it into single coding. I am using call option 3 times.


    Code (vb):
    Sub Plan001()
        Dim A As Range
        Dim SrchRng

        Set SrchRng = ActiveSheet.Range("A1", ActiveSheet.Range("A65536").End(xlUp))
        Do
            Set A = SrchRng.Find("PLAN 0-00001", LookIn:=xlValues)
            If Not A Is Nothing Then A.EntireRow.Delete
        Loop While Not A Is Nothing
    End Sub


    Sub DeleteCodes()
        Dim B As Range
        Dim SrchRng

        Set SrchRng = ActiveSheet.Range("B1", ActiveSheet.Range("B65536").End(xlUp))
        Do
            Set B = SrchRng.Find("..CODES..", LookIn:=xlValues)
            If Not B Is Nothing Then B.EntireRow.Delete
        Loop While Not B Is Nothing
    End Sub


    Sub DeleteRejectmsg()
        Dim B As Range
        Dim SrchRng

        Set SrchRng = ActiveSheet.Range("B2", ActiveSheet.Range("B65536").End(xlUp))
        Do
            Set B = SrchRng.Find("REJECT MESSAGES", LookIn:=xlValues)
            If Not B Is Nothing Then B.EntireRow.Delete
        Loop While Not B Is Nothing
    End Sub
    -------------------------------------------------------------------------------------------
    MOD EDIT: Added Code tag.
    Last edited by a moderator: Mar 15, 2019 at 1:33 PM
  2. vletm

    vletm Excel Ninja

    Messages:
    4,918
  3. Marc L

    Marc L Excel Ninja

    Messages:
    4,274

    Hi !

    Just call each sub within a main sub …​
  4. Abhishek A

    Abhishek A New Member

    Messages:
    25
    I did that.. Thought there will be a better way.. Anyway thank you for your time

Share This Page