Results 1 to 3 of 3

Thread: Copy paste into dynamic column

  1. #1
    Neophyte Lolbert's Avatar
    Join Date
    Apr 2020
    Posts
    2
    Articles
    0
    Excel Version
    Office 365

    Copy paste into dynamic column



    Register for a FREE account, and/
    or Log in to avoid these ads!

    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!

  2. #2
    Neophyte Lolbert's Avatar
    Join Date
    Apr 2020
    Posts
    2
    Articles
    0
    Excel Version
    Office 365
    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.

  3. #3
    Super Moderator p45cal's Avatar
    Join Date
    Dec 2012
    Posts
    1,706
    Articles
    0
    Excel Version
    365
    Code:
    Columns("K:K").Insert
    With Intersect(Columns("C:C"), ActiveSheet.UsedRange)
      .Offset(, 8).Value = .Value
    End With

Posting Permissions

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