+ Reply to Thread
Results 1 to 6 of 6

VBA to Grab Right 4 Characters of Array of Cells and Paste to Same Array

  1. #1
    Registered User
    Join Date
    05-13-2013
    Location
    Salem, Oregon
    MS-Off Ver
    Excel 2010
    Posts
    28

    VBA to Grab Right 4 Characters of Array of Cells and Paste to Same Array

    I have some SSNs that I need to truncate to the last four numbers so I'm not sending full SSNs around.

    Say I have this four-cell array:
    000-00-0000 987-65-4321
    123-45-6789 010-10-1010

    I want to copy and paste so it looks like:
    0000 4321
    6789 1010

    How would I go about doing this? I know how to do it using a helper column with a RIGHT formula and then pasting over as values then deleting the helper column but I'm sure there is a better way to simply remove those left seven characters, right?

    Thanks.

  2. #2
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: VBA to Grab Right 4 Characters of Array of Cells and Paste to Same Array

    Hello,
    here's a suggestion.
    Select the range of cell and run the code :

    Please Login or Register  to view this content.
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

  3. #3
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: VBA to Grab Right 4 Characters of Array of Cells and Paste to Same Array

    Or. Supposing your four-cell array starts in A1.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: VBA to Grab Right 4 Characters of Array of Cells and Paste to Same Array

    No loop required.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-13-2013
    Location
    Salem, Oregon
    MS-Off Ver
    Excel 2010
    Posts
    28

    Re: VBA to Grab Right 4 Characters of Array of Cells and Paste to Same Array

    Thanks all, thread marked as Solved.

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: VBA to Grab Right 4 Characters of Array of Cells and Paste to Same Array

    Thanks for adding rep points.

+ 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] Copy/Paste Array Data into Row Cells
    By Hawk in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-03-2016, 05:42 PM
  2. [SOLVED] Grab data related to array code
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 06-08-2015, 02:11 PM
  3. Testing for blank cells within Copy / Paste Array
    By MizM in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-30-2013, 11:39 PM
  4. Loop new messages containing a table, populate a dynamic array, paste array to Excel
    By laripa in forum Outlook Programming / VBA / Macros
    Replies: 1
    Last Post: 05-19-2013, 07:20 AM
  5. Grab value from array
    By JimP812 in forum Excel General
    Replies: 4
    Last Post: 06-19-2012, 12:53 PM
  6. Array - Copy Formula, Paste as Array
    By lilanngel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-08-2010, 08:20 AM
  7. select variables ranges, copy to array, paste the array in new workbook
    By Mathew in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-01-2005, 05:06 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