Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50151

Macro is pasting Values and I can't figure out why! Help Please

$
0
0
Can anyone see anything in the code below which is causing all my columns to be without formulas once it is done (not just the 4 I intend)? There are 4 columns noted which ARE supposed to be converted to values, but none of the others are supposed to.

As you can see below, the columns being updated are from AH to AQ. There are 4 formulas I add in (AH, AI, AK & AL), and YES, I do want those pasted as values. However, the other columns already have formulas in them (AJ & AM-AQ) and for some reason those are being pasted over as well. I just can't see to see my error. One note, I do delete columns D-M which moves everything to the left. The columns change to:

AH > X
AI > Y
AJ > Z
AK > AA
AL > AB
AM > AC
AN > AD
AO > AE
AP > AF
AQ > AH

Code:

'Defection Rate Tracking
    Sheets("Defection Rate Tracking").Select
    With Selection
    Dim LastRow82 As Long
    LastRow82 = Range("A65535").End(xlUp).Row - 2
    Range("AH3").Select
    ActiveCell.FormulaR1C1 = _
        "=VLOOKUP(RC[-33],'Active Customer Tracking'!C[-33]:C[-4],28,FALSE)"
    Range("AI3").Select
    ActiveCell.FormulaR1C1 = _
        "=VLOOKUP(RC[-34],'Active Customer Tracking'!C[-34]:C[-8],25,FALSE)"
    Range("AH3:AI3").Copy Destination:=Range("AH3:AI3").Resize(LastRow82, 1)
    Range("AH3:AI3").Resize(LastRow82, 1).Copy
    Range("AK3").Select
    ActiveCell.FormulaR1C1 = _
        "=VLOOKUP(RC[-36],'New Customer Tracking'!C[-36]:C[-33],4,FALSE)"
        Range("AK3").Copy Destination:=Range("AK3").Resize(LastRow82, 1)
        Range("AK3").Resize(LastRow82, 1).Copy
    Range("AL3").Select
    ActiveCell.FormulaR1C1 = _
        "=VLOOKUP(RC[-37],'Trial and Lapsed'!C[-37]:C[-33],5,FALSE)"
        Range("AL3").Copy Destination:=Range("AL3").Resize(LastRow82, 1)
        Range("AL3").Resize(LastRow82, 1).Copy
    Columns("D:M").Select
    Selection.Delete Shift:=xlToLeft
    Columns("X:Y").Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Columns("AA:AB").Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
  'NOTE:  Next part added to put a formula back in because it is being copied over     
    Range("AG3").Select
    ActiveCell.FormulaR1C1 = "=RC[-1]/RC[-9]"
        Range("AG3").Copy Destination:=Range("AG3").Resize(LastRow82, 1)
        Range("AG3").Resize(LastRow82, 1).Copy
    End With


Viewing all articles
Browse latest Browse all 50151

Trending Articles