Copy paste into dynamic column

Lolbert

New member
Joined
Apr 8, 2020
Messages
2
Reaction score
0
Points
0
Excel Version(s)
Office 365
Hi

I have this simple VBA code where I run a macro to copy a selection and paste it on a new selection.
What I need is for the code to paste it to the column to the right of where it was previously pasted it, so that I get an expanding range of "stored" values spanning to the right.

My simple code so far:

Code:
    Range("C2:C12").Select
    Selection.Copy
    Range("J2").Select
    ActiveSheet.Paste
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
        
    Range("B19:C31").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("J19").Select
    ActiveSheet.Paste
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False

Any help is appreciated. Thanks in advance!
 
Sorry for posting prematurely, but I solved it.
Probably far from the best solution, but it does the trick for me:

Code:
        Columns("K:K").Select
        Selection.Insert Shift:=xlToRight
        Columns("C:C").Select
        Selection.Copy
        Columns("K:K").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        ActiveSheet.Paste
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False

EDIT: Original code was supposed to copy column C and paste it into column K. Sorry for the confusion.
 
Code:
Columns("K:K").Insert
With Intersect(Columns("C:C"), ActiveSheet.UsedRange)
  .Offset(, 8).Value = .Value
End With
 
Back
Top