+ Reply to Thread
Results 1 to 3 of 3

VBA to give static output of LEFT function

Hybrid View

  1. #1
    Registered User
    Join Date
    06-28-2009
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    12

    VBA to give static output of LEFT function

    What I would like to do is output the first 4 characters of a cell into another cell. eg Cell A1 has "1234 Sydney".

    If I just use the manual formula "=left(A1,4)" it would give me the correct output "1234" in say cell B2, but as a formula.

    As I need to automate this in a macro, how could you code this in VBA to output the String "1234" into cell B2(ie the actual output rather than a formula)?
    Last edited by mcp21x; 07-10-2009 at 11:25 AM.

  2. #2
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628

    Re: VBA to give static output of LEFT function

    You can use this code:
    Range("b2") = Left (Range("a1"),4)
    Regards,
    Antonio

  3. #3
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,446

    Re: VBA to give static output of LEFT function

    Hi,

    Like this:-

    Range("B1").Value = Left(Range("A1").Value, 4)
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

+ 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