Results 1 to 10 of 10

Thread: Change the text within a cell to the text within another cell and paste in another co

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Senior Member
    Join Date
    Jun 2012
    Posts
    337
    Rep Power
    14
    Code:
    sub M_snb()
      sn=sheets(1).cells(1).currentregion.resize(,3)
    
      for j=2 to ubound(sn)
        sn(j,2)=sn(j,3)
        if lcase(left(sn(j,1),3))="ext" then sn(j,2)=""
      next
      sheets(1).cells(1).currentregion.resize(,3)=sn
    
      for each it in sheets(1).cells(1).currentregion.columns(2).specialcells(4)
         it.offset(,1).copy it
      next
    End Sub

  2. #2
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    662
    Rep Power
    15
    Quote Originally Posted by snb View Post
    Code:
    sub M_snb()
      sn=sheets(1).cells(1).currentregion.resize(,3)
    
      for j=2 to ubound(sn)
        sn(j,2)=sn(j,1)
        if lcase(left(sn(j,1),3))="ext" then sn(j,2)=""
      next
      sheets(1).cells(1).currentregion.resize(,3)=sn
    
      for each it in sheets(1).cells(1).currentregion.columns(2).specialcells(4)
         it.offset(,1).copy it
      next
    End Sub
    When I run your code, I just get Column C duplicated in Column B. I think the 3 that you had should be a 1 as shown in red above.
    Last edited by Rick Rothstein; 01-11-2016 at 10:39 PM.

  3. #3
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    662
    Rep Power
    15
    Here is another macro that you can try (it runs quite quickly)...
    Code:
    Sub Test()
      Dim LastRow As Long
      LastRow = Cells(Rows.Count, "A").End(xlUp).Row
      Range("B2:B" & LastRow) = Evaluate(Replace("IF(LEFT(A2:A#,3)=""ext"",C2:C#,A2:A#)", "#", LastRow))
    End Sub

Similar Threads

  1. Replies: 5
    Last Post: 03-09-2013, 09:01 AM
  2. Storing Text Value From Cell To Array
    By marreco in forum Excel Help
    Replies: 2
    Last Post: 02-15-2013, 01:11 AM
  3. Replies: 15
    Last Post: 01-04-2013, 03:26 PM
  4. Replies: 1
    Last Post: 08-21-2012, 07:36 PM
  5. Last Filled Cell Having Text
    By Excel Fox in forum Excel and VBA Tips and Tricks
    Replies: 5
    Last Post: 07-18-2011, 02:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •