+ Reply to Thread
Results 1 to 5 of 5

Macro to leave only the first 8 characters in a range of cells

  1. #1
    Registered User
    Join Date
    10-21-2014
    Location
    Macedonia
    MS-Off Ver
    2010
    Posts
    69

    Macro to leave only the first 8 characters in a range of cells

    Hello all,

    I know this might seem trivial but I was bugging my head with lots of search on the net and could not find the working solution.

    Basically I would like a macro (not a formula in a cell) that will go through column A and leave only the first 8 characters by deleting the rest. The column is populated with text of various length and each time can have various number of rows. All I need is the first 8 characters shown in all rows no matter how many rows there are.

    Thank you so much.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,037

    Re: Macro to leave only the first 8 characters in a range of cells

    Try this:

    Please Login or Register  to view this content.
    Last edited by zbor; 11-19-2014 at 06:43 AM.
    Never use Merged Cells in Excel

  3. #3
    Registered User
    Join Date
    10-21-2014
    Location
    Macedonia
    MS-Off Ver
    2010
    Posts
    69

    Re: Macro to leave only the first 8 characters in a range of cells

    Quote Originally Posted by zbor View Post
    Try this:

    Please Login or Register  to view this content.
    Thank you so much.

    I wonder why the macro stops and the debugger is highlighting the following:

    Please Login or Register  to view this content.
    Once again thank you so much.

    Oh I am sorry, I used column A just to simplify the example. Basically I am filtering the first 8 characters of column P in my spreadsheet if this changes anything. But I already changed the values to:

    Please Login or Register  to view this content.
    Last edited by gokica; 11-19-2014 at 06:57 AM.

  4. #4
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,037

    Re: Macro to leave only the first 8 characters in a range of cells

    Sorry, I've edited post and didn't refresh first...

    Please check now..
    Also, use CODE TAGS around your code.


    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

  5. #5
    Registered User
    Join Date
    10-21-2014
    Location
    Macedonia
    MS-Off Ver
    2010
    Posts
    69

    Re: Macro to leave only the first 8 characters in a range of cells

    Quote Originally Posted by zbor View Post
    Sorry, I've edited post and didn't refresh first...

    Please check now..
    Also, use CODE TAGS around your code.


    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here
    Thank you so much and apologies for not using code tags when inserting a code in my posts. I will follow this rule from now on.

    The macro works wonderful. I have two columns that require this procedure so I will just copy and paste the same code and add the second column in my macro.

    Once again thank you so much. This is most helpful.

    Edit: the code has been edited with the tags in my post above. Thank you.
    Last edited by gokica; 11-19-2014 at 06:58 AM.

+ 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] VBA to Remove 2nd & 3rd Characters from a Range of Cells
    By John_Day83 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-10-2013, 08:25 AM
  2. Help with macro to delete text and leave time in all desired cells
    By ncguy131 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-04-2013, 01:23 PM
  3. Sum first 'x' characters in range of cells
    By Paul987 in forum Excel General
    Replies: 4
    Last Post: 09-02-2009, 02:56 PM
  4. How to delete all the characters in cell and leave just the numbers?
    By yannipr in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-11-2008, 11:23 AM
  5. IF range cells contains 2 same characters
    By antis in forum Excel General
    Replies: 4
    Last Post: 06-15-2008, 08:39 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