+ Reply to Thread
Results 1 to 7 of 7

VBA Left function

  1. #1
    Registered User
    Join Date
    07-15-2006
    Posts
    43

    VBA Left function

    Hello,

    I am trying to use the left function to include only the first account number, for example if a cell has "120122 280000" (there may be many spaces between the two numbers), I only want 120122. So far my programming only returns the 280000 into the cell.

    Here is my programming so far, hope someone can help me ou. I am working with cell values in column "K".

    Please Login or Register  to view this content.
    Last edited by Borg; 02-09-2010 at 02:02 PM.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: VBA Left function

    Couldn't you simply run an Edit Replace replacing: [space]* with nothing ?

    As for the code - I can't see how you're returning 280000 based on your sample.... could you post a sample ?

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: VBA Left function

    Try this:
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    07-15-2006
    Posts
    43

    Re: VBA Left function

    Quote Originally Posted by DonkeyOte View Post
    Couldn't you simply run an Edit Replace replacing: [space]* with nothing ?

    As for the code - I can't see how you're returning 280000 based on your sample.... could you post a sample ?
    Here is an example.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    07-15-2006
    Posts
    43

    Re: VBA Left function

    Quote Originally Posted by shg View Post
    Try this:
    Please Login or Register  to view this content.
    It still seems the same. I'm kind of a noob with VBA.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: VBA Left function

    Runs fine for me in your workbook.

    If you need to preserve the leading zeros then

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    07-15-2006
    Posts
    43

    Smile Re: VBA Left function

    Okay, thanks. It works, I confused myself.
    Last edited by DonkeyOte; 02-09-2010 at 02:06 PM. Reason: unnec. quote removed

+ 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