+ Reply to Thread
Results 1 to 13 of 13

How to combine vba routines?

  1. #1
    Registered User
    Join Date
    05-08-2015
    Location
    Ausralia
    MS-Off Ver
    2013
    Posts
    41

    How to combine vba routines?

    Hey guys I'm coding a few things on a single sheet but im not sure how to combine more that one routine into a sheet. So far I have these:

    Please Login or Register  to view this content.
    and
    Please Login or Register  to view this content.
    They both work separately really well so not sure how to get them to play nicely ive tried putting them under the same Private Sub and then in their own but i get problems each time.
    Note: some of the cell values will be changed when i put it into the sheets vba

    Nick :D

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: How to combine vba routines?

    Hi Nick,

    Perhaps like this:

    Please Login or Register  to view this content.
    Regards,

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  3. #3
    Registered User
    Join Date
    05-08-2015
    Location
    Ausralia
    MS-Off Ver
    2013
    Posts
    41

    Re: How to combine vba routines?

    Ok so that worked, though I have another piece of code which is very similar to the first set, If i were to add it on as well how would i go about doing that? would it be the same process?

  4. #4
    Registered User
    Join Date
    05-08-2015
    Location
    Ausralia
    MS-Off Ver
    2013
    Posts
    41

    Re: How to combine vba routines?

    I have this but it doesnt work with the last routine in it, it works with the first two in it.

    Please Login or Register  to view this content.
    Thanks
    Nick

  5. #5
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: How to combine vba routines?

    Hard to say - if you want add another data validation for when a cell changes you could add another ElseIf statement??

  6. #6
    Registered User
    Join Date
    05-08-2015
    Location
    Ausralia
    MS-Off Ver
    2013
    Posts
    41

    Re: How to combine vba routines?

    My sheet coding is disappearing when i close a spreadsheet and reopen it :/

  7. #7
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: How to combine vba routines?

    My sheet coding is disappearing when i close a spreadsheet and reopen it


    Though this has nothing to with your original question - make sure you save the file as a Excel Macro-Enabled Workbook so that its extension is xlsm. Not sure apart from that.

  8. #8
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: How to combine vba routines?

    hey nick
    your 1st code has 8 cases but the last has 10

    how many did you actually want?
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  9. #9
    Registered User
    Join Date
    05-08-2015
    Location
    Ausralia
    MS-Off Ver
    2013
    Posts
    41

    Re: How to combine vba routines?

    Well there would be a total of 18 cases but 8 of them are constrained by B20 and the other 10 are constrianed by B34 i believe. Is it Not possible to have more than one??

  10. #10
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: How to combine vba routines?

    ok i see the difference

    you can just peg another elseif at the bottom as the trigger is a different target address

    as this new sheet is different to the other ones you provided in the other posts
    however can you not just shorten them the same way with the code i gave you?
    as you dont really need to have so many cases...you just need to increment it based on the DV right?

  11. #11
    Registered User
    Join Date
    05-08-2015
    Location
    Ausralia
    MS-Off Ver
    2013
    Posts
    41

    Re: How to combine vba routines?

    Hey thanks ill try adding another elseif in there and see how it goes, and yeah probably dont need all these cases but i still am not really sure how that code you supplied earlier works. for now im happy with having a bunch of cases, it just needs to work.

    Thanks
    Nick

  12. #12
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: How to combine vba routines?

    Hi Nick

    i wrote an a good chunk of notes for you in the coding to help you try to understand it
    as you said, the case code works for you and if your happy with it then there is no need to rack you brain around learning it

    it is mainly algebra at work but should you want to learn it for the future it is broken down for you

    Cheers
    Hum
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    05-08-2015
    Location
    Ausralia
    MS-Off Ver
    2013
    Posts
    41

    Re: How to combine vba routines?

    It all works now :D thank you to all who helped me <3

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Help with Calling Routines
    By HappyHole in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-07-2011, 04:08 AM
  2. Run 2 Sub routines with 1 macro?
    By confusedvba in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-24-2010, 08:45 PM
  3. Run Sub Routines in Background
    By liav.ezer in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-03-2010, 05:42 AM
  4. [SOLVED] Sorting Routines
    By ADG in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-30-2006, 05:35 AM
  5. [SOLVED] vb dummy - two routines
    By Greg in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-20-2005, 12:05 PM

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