+ Reply to Thread
Results 1 to 11 of 11

Triiming a Cell

  1. #1
    Forum Contributor
    Join Date
    11-02-2010
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    353

    Triiming a Cell

    Hi all,
    Can you help me with this code, it used to work but now for some strange reason it doesn't.
    What I wanted to do is to trim the values in column I and split it to columns J,K,L and M.

    This is the code I was using:

    Please Login or Register  to view this content.
    I have attached my sample worksheet.
    Thank you very much.

    -Andrew
    Attached Files Attached Files
    Last edited by Andrew.Trevayne; 03-08-2017 at 06:41 AM.

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Triiming a Cell

    You're splitting the 5th element of the array with '/' as the delimiter in this line:
    Please Login or Register  to view this content.
    This relates to Column M - Surely you should be splitting the 1st element (Col I)...?

  3. #3
    Forum Contributor
    Join Date
    11-02-2010
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    353

    Re: Triiming a Cell

    Quote Originally Posted by cytop View Post
    You're splitting the 5th element of the array with '/' as the delimiter in this line:
    Please Login or Register  to view this content.
    This relates to Column M - Surely you should be splitting the 1st element (Col I)...?
    Thanks. Yes I need to split column I.
    This was working until I inserted a column back but now I could not longer make it work ;(

  4. #4
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Triiming a Cell

    Inserting/deleting columns does not affect VBA code and I have not checked the actual operation but you could try simply changing the 5 to a 1 in the line I quoted above.

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Triiming a Cell

    You also need to change this line

    Please Login or Register  to view this content.
    INTO

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    11-02-2010
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    353

    Re: Triiming a Cell

    Quote Originally Posted by cytop View Post
    Inserting/deleting columns does not affect VBA code and I have not checked the actual operation but you could try simply changing the 5 to a 1 in the line I quoted above.
    Tried this but it only change the first row on my records and my column I was overwritten (not what I wanted).


    Quote Originally Posted by AB33 View Post
    You also need to change this line

    Please Login or Register  to view this content.
    INTO

    Please Login or Register  to view this content.

    This too didn't work for me. Column I was overwritten and Columns J, K, L and M got the #N/A value

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Triiming a Cell

    Andrew, please do not reply with quote, just use reply.
    See attached.
    If you want the split to go to column J
    Change this line
    Range("I2:M" & Cells(Rows.Count, "I").End(xlUp).Row).Value = arr
    INTO
    Range("J2:M" & Cells(Rows.Count, "I").End(xlUp).Row).Value = arr
    Attached Files Attached Files

  8. #8
    Valued Forum Contributor
    Join Date
    11-26-2012
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    419

    Re: Triiming a Cell

    You can do what you want a bit more directly - try this:
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    11-02-2010
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    353

    Re: Triiming a Cell

    Thanks Gents. None of this is working for me.
    Just to clarify, I wanted to trim the values in column I and split it to columns J,K,L and M. (Column I must not be overwritten).

  10. #10
    Forum Contributor
    Join Date
    11-02-2010
    Location
    Philippines
    MS-Off Ver
    Excel 2003
    Posts
    353

    Re: Triiming a Cell

    Quote Originally Posted by mgs73 View Post
    You can do what you want a bit more directly - try this:
    Please Login or Register  to view this content.

    Okay this actually worked. I just changed "M" to "I".

  11. #11
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Triiming a Cell

    This code works for me.

    Please Login or Register  to view this content.

+ 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] When one cell equals value of another cell, then third cell displays text of fourth cell?
    By spookymyo in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-12-2021, 02:12 PM
  2. Replies: 2
    Last Post: 12-07-2016, 12:39 PM
  3. [SOLVED] Macro Delete Contents in 23rd corresponding cell if the cell in range is a non-blank cell
    By murtaza.khan in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-04-2014, 01:11 AM
  4. If Cell A is equal to Cell B replace the data from Cell A with Cell C. How can I do this.
    By tristanhathaway in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-01-2014, 08:05 PM
  5. [SOLVED] How to create/run "cell A equals Cell B put Cell C info in Cell D
    By abmb161 in forum Excel General
    Replies: 7
    Last Post: 02-05-2014, 02:20 AM
  6. Replies: 1
    Last Post: 11-06-2013, 02:56 AM
  7. Replies: 1
    Last Post: 11-03-2012, 09:05 PM

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