+ Reply to Thread
Results 1 to 10 of 10

Joining two codes into one

  1. #1
    Registered User
    Join Date
    06-26-2015
    Location
    St.Paul, Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    37

    Joining two codes into one

    Hi,

    I've got a code that compiles several sheets into one combined sheet. However, I want to add to my code some adjustments to be made for the newly created combined sheet. The code to compile the data is this:
    Please Login or Register  to view this content.
    And the code I've recorded that I want done to the newly created combined sheet is this:
    Please Login or Register  to view this content.
    Is there a way I can combine these macros into one so that it does both at the same time in the proper sequence? Thanks!

  2. #2
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Joining two codes into one

    Try this.. COnsidering your First execution code is Sub Test()

    Please Login or Register  to view this content.
    Regards
    Parth

    I appreciate your feedback. Hit * if u Like.
    Rules - http://www.excelforum.com/forum-rule...rum-rules.html

  3. #3
    Forum Contributor
    Join Date
    09-26-2014
    Location
    Moscow, Russia
    MS-Off Ver
    MSE 10, MSE 13
    Posts
    179

    Re: Joining two codes into one

    Hi there!

    You may call one macro from another with "Call MacroName" method. Try this one below. I also slightly improved "Macro2".

    Please Login or Register  to view this content.
    Best wishes and have a nice day!

  4. #4
    Valued Forum Contributor
    Join Date
    04-24-2014
    Location
    United States
    MS-Off Ver
    Office 365 ProPlus
    Posts
    853

    Re: Joining two codes into one

    Parth.

    I'm not sure if just calling Macro2 will do the trick as I'm not certain if he finishing on the new "Combined Sheet"

    Another approach is to place this at the end of your Test Macro.

    Note, you also do not need to 'select' something to do something with it.

    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Joining two codes into one

    ptmuldoon True indeed

  6. #6
    Registered User
    Join Date
    06-26-2015
    Location
    St.Paul, Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Joining two codes into one

    Thanks for the replies. Unfortunately I haven't had any sucess yet with either approaches. To clarify the order, my first code trims all of my data sheets, copies just the data, creates a new sheet called "Combined" and then pastes all the data into the combined sheet. I've had sucess with the first code, but I am now trying to join the second code into this same code with the adjustments that I would like to see done to the "Combined" sheet after it has just been created. Basically the adjustments, which you all seem to understand, to the combined sheet are to find blanks within Column B, delete the entire row with blanks found in B, and to also copy the data name down throughout column A, changing as a new name appears. Any further suggestions to combine these codes? Let me know if you need an attachment, because I would have to attempt to remove a bunch of confidential information beforehand. Thanks again!

  7. #7
    Valued Forum Contributor
    Join Date
    04-24-2014
    Location
    United States
    MS-Off Ver
    Office 365 ProPlus
    Posts
    853

    Re: Joining two codes into one

    Try this

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    06-26-2015
    Location
    St.Paul, Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Joining two codes into one

    Its almost there, the only changes that were made to the"Combined" sheet is that the columns A:D were Auto Fit for width, eveyrthing else stayed the same. Selecting blanks in column B and then deleting the entire rows with the blanks was not done, and copying the data name down in Column A was also not done. Thanks!

  9. #9
    Valued Forum Contributor
    Join Date
    04-24-2014
    Location
    United States
    MS-Off Ver
    Office 365 ProPlus
    Posts
    853

    Re: Joining two codes into one

    Sorry about that.

    Replace the bottom half with this
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    06-26-2015
    Location
    St.Paul, Minnesota
    MS-Off Ver
    Excel 2010
    Posts
    37

    Re: Joining two codes into one

    Thanks, that did the trick! Quick question: Now that I'm looking at my data, is there a way I could add into the code a step that Filters column B to show any Numbers or Blank cells? I'd like to delete all those values as well, but I'm not sure if this can be done through code. Thanks again to Ptmuldoon and others for the replies.

+ 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. Replies: 1
    Last Post: 12-10-2013, 12:28 AM
  2. Replies: 0
    Last Post: 10-09-2013, 07:59 PM
  3. [SOLVED] Addresses - truncate 11 digit zip codes and leave 5 digit zip codes
    By landisf in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-25-2013, 11:15 PM
  4. Filter Zip Codes from a list codes
    By jaugent27 in forum Excel General
    Replies: 3
    Last Post: 06-11-2013, 02:01 PM
  5. Replies: 1
    Last Post: 04-15-2013, 05:16 PM
  6. Combining vba codes makes the previous codes broken !
    By MDPLUS in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-26-2013, 10:00 AM
  7. Replies: 6
    Last Post: 11-28-2006, 01:08 PM
  8. matching codes between 2 item codes
    By JChan in forum Excel General
    Replies: 1
    Last Post: 10-15-2005, 01:05 AM

Tags for this Thread

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