+ Reply to Thread
Results 1 to 4 of 4

How can I assign the last 4 characters of a string to a string variable?

  1. #1
    Valued Forum Contributor
    Join Date
    02-21-2010
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2007
    Posts
    502

    How can I assign the last 4 characters of a string to a string variable?

    I have the following type of strings: (3 examples)

    BMC Nephrology (2015) 16:1 Article Number: 38. Date of Publication: 1 Dec 2015
    Toxicology (2015) 333 (89-99). Date of Publication: 3 Jul 2015
    Clinical Chemistry and Laboratory Medicine (2015) 53 SUPPL. 1 (S1043). Date of Publication: July 2015

    I want to assign the last 4 characters, which is always a year, to string variable.

    How can I do this in a VBA?

  2. #2
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: How can I assign the last 4 characters of a string to a string variable?

    You can use the Right function, similar to the Excel function RIGHT.

    Please Login or Register  to view this content.
    Will result in "2015"

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

    Re: How can I assign the last 4 characters of a string to a string variable?

    Please Login or Register  to view this content.
    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.

  4. #4
    Valued Forum Contributor
    Join Date
    02-21-2010
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2007
    Posts
    502

    Re: How can I assign the last 4 characters of a string to a string variable?

    humdingaling, perfect! Thank you very much.

+ 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. [SOLVED] Assign values to case sensitive characters within string
    By tbsweet52 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-01-2015, 05:37 PM
  2. Assign activesheet name to string variable?
    By MickeyGreen in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-14-2007, 12:08 PM
  3. [SOLVED] Special characters in a string variable
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-04-2006, 03:40 PM
  4. [SOLVED] How do I find a specific characters position in a string variable
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-11-2006, 10:30 AM
  5. Pass multiple characters to a string variable
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-19-2005, 06:26 AM

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