+ Reply to Thread
Results 1 to 10 of 10

Combine vba codes

  1. #1
    Registered User
    Join Date
    04-19-2010
    Location
    dublin, ireland
    MS-Off Ver
    Excel 2007
    Posts
    10

    Combine vba codes

    Hi
    I have large text files to convert and I would like to get all the codes combined into one, if thats possible.

    The text i want to parse has various quantity of 7 character partnumbers at the end. one piece of code splits the string out and the following formula can remove all the pieces split out from the original string so basically i have the fully original string and then the string split out into the individual parts.

    I cant find the vba for this formula but i have placed it below where it should run

    =LEFT(A1,SEARCH(B1,A1)-1)

    Can somebody take a look at that and maybe combine the formula and the following code into one piece?

    The code is in the order I'd like it performed - with the formula inserted where it should be.

    The one issue i found while testing the individual pieces is that most of them require the columns to be manually selected which i would prefer to happen automatically

    (I've found all this vba on the net)

    Thanks
    John


    Please Login or Register  to view this content.


    Please Login or Register  to view this content.




    Please Login or Register  to view this content.


    Please Login or Register  to view this content.


    Please Login or Register  to view this content.
    Last edited by mmwltd; 04-22-2010 at 08:36 AM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Combine vba codes

    If you post a sample workbook showing a few rows of the BEGINNING DATA and then a mockup of those same rows after your macros have run showing your desired END RESULT, this would be simplest to offer the best answer.

    Click GO ADVANCED and use the paperclip icon to post up your workbook.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    04-19-2010
    Location
    dublin, ireland
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Combine vba codes

    Hi

    I've attached a few sample lines of beginning data and end result required.

    Thanks
    Last edited by mmwltd; 04-19-2010 at 04:09 PM.

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Combine vba codes

    This should do it:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-19-2010
    Location
    dublin, ireland
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Combine vba codes

    Thanks for that. I've tried it on a small sample of data and it works great. I've noticed that it doesn't to CLEAN the text (I don't know if it TRIMs it)
    Will it still work if i use formulas to CLEAN and TRIM the text first or should i run the vba then CLEAN and TRIM?

    I just want to make sure i dont mess things up because it'll be very difficult to see if something goes wrong until a customer complains!

    Thanks again
    John

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Combine vba codes

    Replace that one macro with these two, the second Function is used by the first to properly clean out any hidden junk.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    04-19-2010
    Location
    dublin, ireland
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Combine vba codes

    Quote Originally Posted by JBeaucaire View Post
    Replace that one macro with these two, the second Function is used by the first to properly clean out any hidden junk.
    Because all this is new to me I have what is probably a very dumb question

    I copied and pasted the original macro into excel so do i just copy and paste these two over the original or do i need to save the two new macros in separate files?

    Thanks

  8. #8
    Registered User
    Join Date
    04-19-2010
    Location
    dublin, ireland
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Combine vba codes

    Hi

    Is there a way to limit the CLEAN portion of this macro to just unprintable characters and extra spaces because some of the text has "-" and "@" that need to stay.

    Thanks

  9. #9
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Combine vba codes

    in the CLEANALL function, add the characters you want allowed into the match pattern. Be sure not to delete the blank space in there:

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    04-19-2010
    Location
    dublin, ireland
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Combine vba codes

    Thanks very much for all your help

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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