+ Reply to Thread
Results 1 to 8 of 8

VB Code to delete last character

  1. #1
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    3,961

    VB Code to delete last character

    Hello:

    Please refer to sample txt file as attached.
    I need a vb code to delete the last 8 characters of line#5

    As in the attached file, Line # 5 is
    RX408282,20150630,,,,,,,,

    and it needs to be

    RX408282,20150630

    Please let me know if you have any questions.
    Thanks.

    Riz
    Attached Files Attached Files
    Last edited by rizmomin; 07-07-2015 at 07:33 PM.

  2. #2
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,736

    Re: VB Code to delete last character

    I know you need a vba code but here is very easy formula that may help.

    =SUBSTITUTE(SUBSTITUTE(A1,",,",""),",","",2)

    Row\Col
    A
    B
    1
    RX1008818,20150630 RX1008818,20150630
    2
    RX5008819,20150630 RX5008819,20150630
    3
    RX2008071,20150630 RX2008071,20150630
    4
    RX362089,20150630 RX362089,20150630
    5
    RX408282,20150630,,,,,,,, RX408282,20150630
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  3. #3
    Valued Forum Contributor
    Join Date
    04-24-2014
    Location
    United States
    MS-Off Ver
    Excel 2013 x64
    Posts
    639

    Re: VB Code to delete last character

    This will trim the last 8 characters of the cell with VBA as well

    Please Login or Register  to view this content.
    Last edited by ptmuldoon; 07-07-2015 at 08:51 PM.

  4. #4
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    3,961

    Re: VB Code to delete last character

    Hello:

    I need to trim the 5th line of txt file.
    Assume that txt file is in C:\Temp\ folder and neeed VB macro in excel file
    Please let me know if you have any questions.
    Thanks.

    Riz
    Last edited by rizmomin; 07-08-2015 at 01:49 AM.

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013
    Posts
    13,764

    Re: VB Code to delete last character

    This should do
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    06-13-2015
    Location
    Pakistan
    MS-Off Ver
    2010
    Posts
    6

    Need help with visual basic macros

    Dear All
    First of all, I don’t know how to create a new post, though I need everybody help in one assignment.

    Attached is the invoice file, I created it using MS Excel 2010, while its for my friend who is using Excel 2007.

    He is also not so aware with excel and complaining continuously that macro of save invoice is not working, so I freshly record a macro to create pdf file, I need your help to know if i will work on 2007 as well.

    Plus, I have seen that macros “Save_Data” “Print” “Next_New” is working fine, you can also check and do advice if you feel it can be better further.

    While Macro “Save_Invoice” is also working fine but I just want it to be save with file name as value in cell D5 & D4 which is customer and Invoice# and it should save in same destination folder as in original excel file, because I will send this file by email to him and he will save it anywhere in his computer.

    Need your sincere help with advance thanks.
    Attached Files Attached Files

  7. #7
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    3,961

    Re: VB Code to delete last character

    Hi Jindon:

    Your solution works great, thanks a lot

    Riz

  8. #8
    Valued Forum Contributor
    Join Date
    01-18-2007
    Location
    Georgia
    MS-Off Ver
    2010
    Posts
    3,961

    Re: VB Code to delete last character

    Hi Jindon:

    Your solution works great, thanks a lot

    Riz

+ 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