+ Reply to Thread
Results 1 to 6 of 6

macro for copying alpha numeric numbers from txt

  1. #1
    Forum Contributor
    Join Date
    04-01-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    128

    macro for copying alpha numeric numbers from txt

    Hi,

    I have a macro which copies 9 digit numbers from a txt file as well as alpha numeric numbers from a txt files. But the problem is it only copies numbers till 4 alphabetic. I am attaching both excel macro as well as txt file. I need all the numbers to get copied. Thanks a lot!
    Attached Files Attached Files

  2. #2
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: macro for copying alpha numeric numbers from txt

    Why use a macro?
    Can't you just open the text file with Excel?

    File > Open ... Files of type:= Text Files(*.prn,*txt,*csv) select your text file then press "Open" and follow the wizard.

    If there are strings in your text file that are more, or less, than 9 characters, (there aren't any in your sample .txt), then in B2
    Please Login or Register  to view this content.
    Drag Down

    Filter out the values that are equal to 9 and delete the remaining rows.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  3. #3
    Forum Contributor
    Join Date
    04-01-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: macro for copying alpha numeric numbers from txt

    I need macro as I do not get the txt file like i have attached as an example. I get a txt with jumbled words and numbers as the txt is imported from a pdf file.

  4. #4
    Forum Contributor
    Join Date
    06-09-2011
    Location
    Germany
    MS-Off Ver
    Excel 2016
    Posts
    194

    Re: macro for copying alpha numeric numbers from txt

    Hi,

    the line "\b\d{9}\b|\b\w{9}\d{5}\b" defines which strings need to be copied and which aren't. If you google for "Regular Expressions" you will find loads of information who that functionality works. Without knowing what data is actually contained in your pdf file and without knowing which 9 digit strings need to be copied and which shouldn't we can only guess.

    Regards

    Theo
    Remember To Do the Following....
    1. Upload sample files
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.

  5. #5
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: macro for copying alpha numeric numbers from txt

    I need macro as I do not get the txt file like i have attached as an example ...
    So why post it as an example of your problem ...

  6. #6
    Forum Contributor
    Join Date
    04-01-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: macro for copying alpha numeric numbers from txt

    I have already searched that...As am not so good in excel as well as in VBA...I couldnt understand about it. The code which you gave is also not what I want. What I need is :

    Macro to copy 9 digit alpha numeric numbers which would include 4 alphas or max 5 alphas! The excel which i copied copies till 4 alpha and total 9 numeric and it misses some of the container numbers!!

    Thank you

+ 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