+ Reply to Thread
Results 1 to 5 of 5

VBA to copy formulas in column D and paste as values in same column

Hybrid View

maacmaac VBA to copy formulas in... 01-09-2012, 10:03 PM
davesexcel Re: VBA to copy formulas in... 01-09-2012, 10:07 PM
davesexcel Re: VBA to copy formulas in... 01-09-2012, 10:17 PM
maacmaac Re: VBA to copy formulas in... 01-09-2012, 10:38 PM
snb Re: VBA to copy formulas in... 01-10-2012, 05:18 AM
  1. #1
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,176

    VBA to copy formulas in column D and paste as values in same column

    I have create a formula in column D. Once the formula is created, I want to copy and paste as values. I am try to make the code more efficient by not having select the cells in the process. I've tried both methods below, but can't get either to work. Thanks

    Range("D2:D" & Lastrow).FormulaR1C1 = "=IF(LEFT(RC[8],3)=""TEN"",""RR-12"","""")"
    Range("D2:D" & Lastrow) = Range("D2:2" & Lastrow).Value
    Range("D2:D" & Lastrow).FormulaR1C1 = "=IF(LEFT(RC[8],3)=""TEN"",""RR-12"","""")"
    Columns("D:D").copy Destination:=Columns("D:D")Paste:=xlPasteValues
    Last edited by maacmaac; 01-09-2012 at 10:38 PM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525

    Re: VBA to copy formulas in column D and paste as values in same column

    Hello, have you supplied us with the complete code you are using?

  3. #3
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525

    Re: VBA to copy formulas in column D and paste as values in same column

    For example
    Dim LastRow As Long, Rng As Range
    LastRow = Cells(Rows.Count, "A").End(xlUp).Row
    Set Rng = Range("D2:D" & LastRow)
    Rng = "=IF(LEFT(RC[8],3)=""TEN"",""RR-12"","""")"
    Rng = Rng.Value

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

    Re: VBA to copy formulas in column D and paste as values in same column

    That will work. Thanks for the comment.

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: VBA to copy formulas in column D and paste as values in same column

    Alternative method:
    Sub snb()
      Sheet1.Cells(1).CurrentRegion.Columns(1).Name = "snb2a"
      [snb2a].Offset(, 3) = [if(left(offset(snb2a,,7),3)="TEN","RR-12","")]
    End Sub



+ 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