+ Reply to Thread
Results 1 to 6 of 6

left() for single cell?

  1. #1
    Registered User
    Join Date
    11-09-2009
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    52

    left() for single cell?

    I am trying to use the 'left()' command on a single cell of data within a macro. For example, if I want to limit A1 to 5 characters from the left, what would the code look like?

    Apologies if this is an easy one, I have searched around and I can't get it right. *sigh*

    Thanks!
    Last edited by mpkavanagh; 01-12-2011 at 06:30 PM.

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: left() for single cell?

    Hello,

    something along the lines of

    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: left() for single cell?

    Please Login or Register  to view this content.
    To control number of symbols you can use in-built validation tool.

  4. #4
    Registered User
    Join Date
    11-09-2009
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    52

    Re: left() for single cell?

    Not working. Do I need to declare anything? I am very new to VBA and programming in general and I am learning through trial/error...

    For example:

    Please Login or Register  to view this content.

    Is what I have. I am thinking I am missing something...

  5. #5
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: left() for single cell?

    You will have to write the result back into the cell, of course, like watersev shows, or using the Range() long hand.

    Please Login or Register  to view this content.
    I'm not sure what you mean by "I want to limit". You'll need to explain a bit more what you want to do or post a workbook with before and after so we can see what you want to achieve.

  6. #6
    Registered User
    Join Date
    11-09-2009
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    52

    Re: left() for single cell?

    Thanks! It worked. I appreciate the speedy help.

    By "limit" I meant keep only a certain number of characters. Basically, I wanted 123456 to return 1234 if I chose 4 characters.

+ 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