Application.left VBA

Discussion in 'Microsoft Excel Misc' started by Jeff, Jan 30, 2009.

  1. Jeff

    Jeff Guest

    Can somenone help fixing the VBA macro?
    Sub trimit()
    Dim rng As Range
    Set target = Range("A2:H" & Range("A2").End(xlDown).Row)
    Set rng1 = Range("F2:H" & Range("F2").End(xlDown).Row)
    For Each cell In target
    cell.Value = Trim(Application.Left(Range("target")), 10, 0
    Range("rng1") = cell.Value
    Next
    End Sub
     
    Jeff, Jan 30, 2009
    #1
    1. Advertisements

  2. Jeff

    Don Guillett Guest

    maybe to get the left 10 characters in cell F.

    Sub trimit()
    for each c in Range("A2:H" & Range("A2").End(xlDown).Row)
    c.Value = left(c.offset(,5),10)
    'or to trim the cell first and then get the left 10
    'c.Value = left(application.trim(c.offset(,5)),10)

    Next c
    End Sub


    --
    Don Guillett
    Microsoft MVP Excel
    SalesAid Software

    "Jeff" <> wrote in message
    news:...
    > Can somenone help fixing the VBA macro?
    > Sub trimit()
    > Dim rng As Range
    > Set target = Range("A2:H" & Range("A2").End(xlDown).Row)
    > Set rng1 = Range("F2:H" & Range("F2").End(xlDown).Row)
    > For Each cell In target
    > cell.Value = Trim(Application.Left(Range("target")), 10, 0
    > Range("rng1") = cell.Value
    > Next
    > End Sub
    >
     
    Don Guillett, Jan 30, 2009
    #2
    1. Advertisements

  3. Jeff

    Jeff Guest

    What I need is to put the value c in column F after "left" and "trim".


    "Jeff" wrote:

    > Can somenone help fixing the VBA macro?
    > Sub trimit()
    > Dim rng As Range
    > Set target = Range("A2:H" & Range("A2").End(xlDown).Row)
    > Set rng1 = Range("F2:H" & Range("F2").End(xlDown).Row)
    > For Each cell In target
    > cell.Value = Trim(Application.Left(Range("target")), 10, 0
    > Range("rng1") = cell.Value
    > Next
    > End Sub
    >
     
    Jeff, Jan 30, 2009
    #3
  4. Jeff

    Don Guillett Guest

    If? you are saying you want the right, then have a look at RIGHT and LEN

    --
    Don Guillett
    Microsoft MVP Excel
    SalesAid Software

    "Jeff" <> wrote in message
    news:...
    > What I need is to put the value c in column F after "left" and "trim".
    >
    >
    > "Jeff" wrote:
    >
    >> Can somenone help fixing the VBA macro?
    >> Sub trimit()
    >> Dim rng As Range
    >> Set target = Range("A2:H" & Range("A2").End(xlDown).Row)
    >> Set rng1 = Range("F2:H" & Range("F2").End(xlDown).Row)
    >> For Each cell In target
    >> cell.Value = Trim(Application.Left(Range("target")), 10, 0
    >> Range("rng1") = cell.Value
    >> Next
    >> End Sub
    >>
     
    Don Guillett, Jan 30, 2009
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest

    How to set left column against left margin?

    Guest, Sep 29, 2004, in forum: Microsoft Excel Misc
    Replies:
    1
    Views:
    202
    Anne Troy
    Sep 29, 2004
  2. Guest
    Replies:
    1
    Views:
    361
    Dave Peterson
    Jul 4, 2005
  3. Guest

    Column labels run right to left, not left to right

    Guest, Nov 10, 2006, in forum: Microsoft Excel Misc
    Replies:
    1
    Views:
    212
    Guest
    Nov 10, 2006
  4. Guest

    Left vs Left$ function

    Guest, May 5, 2007, in forum: Microsoft Excel Misc
    Replies:
    5
    Views:
    3,034
    James Silverton
    May 6, 2007
  5. Akash Puri

    My Excel view is Right to Left instead of Left to Right !!!

    Akash Puri, May 5, 2008, in forum: Microsoft Excel Misc
    Replies:
    2
    Views:
    473
    Dave Peterson
    May 5, 2008
Loading...

Share This Page