Adding Multiple VBA Codes to the Same Sheet

  • I am attempting to create a code that copies a row to another sheet based on selections in columns G and F. I cannot figure out how to run both at once!




    I am attempting to run this code:



    --------------------------------------------------------------------------


    At the same time as running the code below:


    Code
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("F:F")) Is Nothing Then Exit Sub
    If Target = "Clouded" Then
    Target.EntireRow.Copy Sheets("Radi").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
    End If
    If Intersect(Target, Range("F:F")) Is Nothing Then Exit Sub
    If Target = "Faxed" Then
    Target.EntireRow.Copy Sheets("Fax").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
    End If
    End Sub


    ----------------------------------------------------------------------------


    How can I run both at the same time?

  • Code Tags Added
    Your post does not comply with our Forum RULES. Use code tags around code.


    Posting code between

    Code

    tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.


    Highlight your code and click the # icon at the top of your post window.


    (I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)

  • You can not run them at the same time, but you could have another macro that calls each one consecutively.


    Something like this:


    Code
    Sub RunAll()    
    Call Macro1    
    Call Macro2    
    Call Macro3
    End Sub


    change the macro names as needed.

  • Hello,


    You could test the following :



    Hope this will help

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Thumbs Up" icon, below, in the bottom right corner:)

  • You cannot use `If Intersect(Target, Range("G:G")) Is Nothing Then Exit Sub` if you intend on using additional columns for target ranges.

Participate now!

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