+ Reply to Thread
Results 1 to 2 of 2

copy characters in cell to other cell less first 3 characters.

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,173

    copy characters in cell to other cell less first 3 characters.

    I am trying to copy data from one cell to another less the first 3 characters of the source cell.

    For example:
    in cell G2 is value "XXXJoe Smith". In cell M2 I want copy as "Joe Smith".
    in cell G3 is value "ABCPat Smith". In cell M3 I want copy as "Pat Smith".
    in cell G4 is value "YRTSue Smith". In cell M4 I want copy as "Sue Smith".

    Is there a way to incorporate this into the code?

        With ActiveSheet
            LastRow = .Cells(Rows.Count, 1).End(xlUp).Row
                For i = 2 To LastRow
                    .Range("M2:M" & LastRow).Value = .Range("G2:G" & LastRow).Value
                Next i
            End If
        End With

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,643

    Re: copy characters in cell to other cell less first 3 characters.

    try
    Sub test()
        With Range("g2", Range("g" & Rows.Count).End(xlUp))
            .Offset(, 6).Value = _
            Evaluate("if(row(" & .Address & "),mid(" & _
            .Address & ",4,len(" & .Address & ")))")
        End With
    End Sub
    Last edited by jindon; 04-20-2012 at 11:48 PM. Reason: Code edoted

+ 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