Consulting

Results 1 to 2 of 2

Thread: Insert Vba macro to Sheet 3 using another macro.

  1. #1
    VBAX Regular
    Joined
    Dec 2017
    Posts
    12
    Location

    Insert Vba macro to Sheet 3 using another macro.

    hello,

    I have a job quoting spread sheet that has 22 sheets in it.
    i am constantly making revisions to it and i have created a macro that allows me to bring older versions up to the current revision if needed.
    i would like to add these 2 macro inside sheet 3.
    I am not sure how to make it go in sheet 3 or any other sheet.
    any help would be appreciated

    thanks
    Jeffrey

    Sub Include_All()
    Range("I9,K9,M9,O9,Q9,S9,U9,W9,Y9,AA9,AC9,AE9,AG9,AI9,AK9,AM9,AO9,AQ9,AS9,A U9,AW9,AY9,BA9,BC9,BE9,BG9,BI9,BK9,BM9,BO9,BQ9,BS9,BU9,BW9,BY9,CA9,CC9,CE9, CG9,CI9,CK9,CM9,CO9,CQ9,CS9,CU9,CW9,CY9,DA9,DC9,DE9,DG9,DI9,DK9,DM9,DO9,DQ9 ,DS9,DU9,DW9,DY9") = "Yes"
    Range("EA9,EC9,EE9,EG9,EI9,EK9,EM9,EO9,EQ9,ES9,EU9,EW9,EY9,FA9,FC9,FE9,FG9, FI9,FK9,FM9,FO9,FQ9,FS9,FU9,FW9,FY9,GA9,GC9,GE9,GG9,GI9,GK9,GM9,GO9,GQ9,GS9 ,GU9,GW9,GY9,HA9,HC9,HE9,HG9,HI9,HK9,HM9,HO9,HQ9,HS9,HU9,HW9,HY9,IA9,IC9,IE 9,IG9,II9,IK9,IM9,IO9,IQ9,IS9,IU9") = "Yes"
    Range("IW9,IY9,JA9,JC9,JE9,JG9,JI9,JK9,JM9,JO9,JQ9,JS9,JU9,JW9,JY9,KA9,KC9, KE9,KG9,KI9,KK9,KM9,KO9,KQ9,KS9,KU9,KW9,KY9,LA9,LC9,LE9,LG9,LI9,LK9,LM9,LO9 ,LQ9,LS9,LU9,LW9,LY9,MA9,MC9,ME9,MG9,MI9,MK9,MM9,MO9,MQ9,MS9,MU9,MW9,MY9,NA 9,NC9,NE9,NG9,NI9,NK9,NM9,NO9,NQ9") = "Yes"
    Range("NS9,NU9,NW9,NY9,OA9,OC9,OE9,OG9,OI9,OK9,OM9,OO9,OQ9") = "Yes"
    End Sub
    Sub Exclude_All()
    Range("I9,K9,M9,O9,Q9,S9,U9,W9,Y9,AA9,AC9,AE9,AG9,AI9,AK9,AM9,AO9,AQ9,AS9,A U9,AW9,AY9,BA9,BC9,BE9,BG9,BI9,BK9,BM9,BO9,BQ9,BS9,BU9,BW9,BY9,CA9,CC9,CE9, CG9,CI9,CK9,CM9,CO9,CQ9,CS9,CU9,CW9,CY9,DA9,DC9,DE9,DG9,DI9,DK9,DM9,DO9,DQ9 ,DS9,DU9,DW9,DY9") = "No"
    Range("EA9,EC9,EE9,EG9,EI9,EK9,EM9,EO9,EQ9,ES9,EU9,EW9,EY9,FA9,FC9,FE9,FG9, FI9,FK9,FM9,FO9,FQ9,FS9,FU9,FW9,FY9,GA9,GC9,GE9,GG9,GI9,GK9,GM9,GO9,GQ9,GS9 ,GU9,GW9,GY9,HA9,HC9,HE9,HG9,HI9,HK9,HM9,HO9,HQ9,HS9,HU9,HW9,HY9,IA9,IC9,IE 9,IG9,II9,IK9,IM9,IO9,IQ9,IS9,IU9") = "No"
    Range("IW9,IY9,JA9,JC9,JE9,JG9,JI9,JK9,JM9,JO9,JQ9,JS9,JU9,JW9,JY9,KA9,KC9, KE9,KG9,KI9,KK9,KM9,KO9,KQ9,KS9,KU9,KW9,KY9,LA9,LC9,LE9,LG9,LI9,LK9,LM9,LO9 ,LQ9,LS9,LU9,LW9,LY9,MA9,MC9,ME9,MG9,MI9,MK9,MM9,MO9,MQ9,MS9,MU9,MW9,MY9,NA 9,NC9,NE9,NG9,NI9,NK9,NM9,NO9,NQ9") = "No"
    Range("NS9,NU9,NW9,NY9,OA9,OC9,OE9,OG9,OI9,OK9,OM9,OO9,OQ9") = "No"
    End Sub

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    This might be a little less brute force and probably less error prone

    This uses the ActiveSheet, which is ... the sheet that is active ... and should probably be placed in a Standard Module

    In the editor, Insert, Module, and paste the macro into that sheet

    Capture.JPG

    You can run the macro any way that you choose: Alt-F8, button, etc.


    Option Explicit
    
    Sub Include_All_1()
        Dim i As Long
        
        For i = 9 To 407 Step 2
            ActiveSheet.Cells(9, i) = "Yes"
        Next i
    End Sub
    
    Sub Exclude_All_1()
        Dim i As Long
        
        For i = 9 To 407 Step 2
            ActiveSheet.Cells(9, i) = "No"
        Next i
    End Sub
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •